title: Permissions error when saving file (sandbox)
body: <p>I'm trying to save a file to a path, in a sandboxed application [OS X], but so far am getting an error almost every time I try to save. The error is..</p>
  
  <pre><code>Error saving: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “test.txt” in the folder “Testing”." UserInfo=0x1001f5e70 {NSFilePath=/Users/Seb/Desktop/Testing/test.txt, NSUnderlyingError=0x1001f5d70 "The operation couldn’t be completed. Operation not permitted"}
  </code></pre>
  
  <p>I have set "User Selected File" of my entitlements to "Read/Write Access".</p>
  
  <p>My code..</p>
  
  <pre><code>NSString *saveLoc = [NSString stringWithFormat:@"%@/%@.txt",[[NSURL URLWithString:[[NSUserDefaults standardUserDefaults] valueForKey:@"saveURL"]] path],self.theWindow.title];
  NSURL *saveURL = [NSURL fileURLWithPath:saveLoc];
  
  NSLog(@"Saving to: %@",saveLoc);
  
  NSError *err = nil;
  [self.textView.string writeToURL:saveURL atomically:YES encoding:NSUTF8StringEncoding error:&amp;err];
  
  if (err) {
      NSLog(@"Error saving: %@",err);
      [[NSAlert alertWithError:err] beginSheetModalForWindow:self.theWindow
                                                         modalDelegate:nil
                                                        didEndSelector:NULL
                                                           contextInfo:nil];
  }
  </code></pre>
  
  <p>What am I doing wrong? How can I save the file?</p>
  
  <p>Thanks.</p>