title: Saving NSString with writeToFile will only save to one location
body: <p>Using the code below is the only way I can get <code>writeToFile</code> to actually save a file. It outputs to this directory:</p>
  
  <blockquote>
    <p>/Users/Eric/Library/Containers/net.ericmann.Event-Gadget-Workshop-App/Data/Documents/gadget.ics</p>
  </blockquote>
  
  <pre><code>- (IBAction)Saved:(id)sender { 
      [self writeToTextFile];
      //mySaved.stringValue = [NSString stringWithFormat:@"Saved!"];
  }
  
  
  -(void) writeToTextFile{
      //get the documents directory:
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  
      //NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
  
  
      //NSString *pathToDesktop = [NSString stringWithFormat:@"/Users/%@/Desktop", NSUserName()];
  
  
      //make a file name to write the data to using the documents directory:
      NSString *fileName = [NSString stringWithFormat:@"%@/gadget.ics", documentsDirectory];
  
      //create content - four lines of text
      NSString *content = myOutput.stringValue;
  
      //save content to the documents directory
      [content writeToFile:fileName atomically:NO encoding:NSStringEncodingConversionAllowLossy error:nil];
      mySaved.stringValue = fileName;
      myTestBox.stringValue = fileName;
  }
  </code></pre>
  
  <p>Now, if I use the code below, nothing will write. I have the test file name output, and it's pointing here:</p>
  
  <blockquote>
    <p>/Users/Eric/Desktop/gadget.ics</p>
  </blockquote>
  
  <pre><code>-(void) writeToTextFile{
      //get the documents directory:
  
      // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  NSUserDomainMask, YES);
  
      //NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
      //NSString *documentsDirectory = [paths objectAtIndex:0];
  
  
      NSString *pathToDesktop = [NSString stringWithFormat:@"/Users/%@/Desktop", NSUserName()];
  
      //make a file name to write the data to using the documents directory:
      NSString *fileName = [NSString stringWithFormat:@"%@/gadget.ics", pathToDesktop];
  
      //create content - four lines of text
      NSString *content = myOutput.stringValue;
  
      //save content to the documents directory
      [content writeToFile:fileName atomically:NO  encoding:NSStringEncodingConversionAllowLossy error:nil];
      mySaved.stringValue = fileName;
      myTestBox.stringValue = fileName;
  </code></pre>