title: Write to a file Xcode MacOS
body: <p>I'm unable to run this piece of code which writes the pid to a file.</p>
  
  <pre><code>NSString *text = [NSString stringWithFormat:@"%d\n", getpid()];
  NSError *error = nil;
  
  if (![text writeToFile:@"/tmp/Frontend.pid" atomically:YES encoding:NSUTF8StringEncoding error:&amp;error]) {
      NSLog(@"Cannot write PID file %@: %@", @"/tmp/Frontend.pid", error);
      return NO;
  }
  </code></pre>
  
  <p>This is the error I get.</p>
  
  <p>2017-11-13 20:19:18.742171+0530 TestThread[7648:273326] Cannot write PID file /tmp/Frontend.pid: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “Frontend.pid” in the folder “tmp”." UserInfo={NSFilePath=/tmp/Frontend.pid, NSUnderlyingError=0x6040000432a0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}</p>
  
  <p>I've changed the permission for the directory to 777 and it still doesn't have enough permissions. Please help.</p>