title: Writing a NSArray to file
body: <p>I am trying to save/write an Array to the documents directory, and I am completely stuck. I have checked this code with multiple sources online. I switched from and NSArray to a NSMutableArray and that didn't work. From what I can tell is the file isn't being written, because test is coming back null. Thanks in advance</p>
  
  <pre><code>NSArray *results = [parser objectWithData:data1];
  
  NSMutableArray *array2 = [[NSMutableArray alloc] initWithArray:results];
  // Create a dictionary from the JSON string  
  
  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *path = [documentsDirectory stringByAppendingPathComponent:@"EmployeeData.plist"];
  
  //NSLog(@"the path is %@, the array is %@", path, array2);
  
  /////write to file/////
  [array2 writeToFile:path atomically:YES];
  
  NSMutableArray *test = [[NSMutableArray alloc ]initWithContentsOfFile:path];
  
  NSLog(@"the test is %@", test);
  </code></pre>
  
  <p>** update **</p>
  
  <p>I added these lines of code</p>
  
  <pre><code>BOOL write = [results writeToFile:path atomically:YES];
  
  NSLog(@"did it right? %@", write);
  </code></pre>
  
  <p>and write is null, what does that mean?</p>
  
  <p>This is one of the many objects in my Array</p>
  
  <pre><code>{
       0 = "&lt;null&gt;";
      1 = "John Doe";
      10 = 512;
      11 = "&lt;null&gt;";
      12 = 1;
      13 = 1;
      2 = Doe;
      3 = Jon;
      4 = "&lt;null&gt;";
      5 = johndoe;
      6 = "&lt;null&gt;";
      7 = "&lt;null&gt;";
      8 = "john@doe.com";
      9 = "&lt;null&gt;";
      Type = 1;
      Active = 1;
      Depart = "&lt;null&gt;";
      Emp = "&lt;null&gt;";
      Ext = "&lt;null&gt;";
      FirstName = Jim;
      Fl = 512;
      Name = "John Doe";
      Log = jd;
      Mobile = "&lt;null&gt;";
      Title = "&lt;null&gt;";
  }
  </code></pre>
  
  <p>Do the null values have anything to do with it?</p>
  
  <p>SOLVED!!</p>
  
  <p>I realized that the null values may have been causing some issues, so i changed my query to take care of that and it saved instantly. The above code is 100% correct and it works!</p>
  
  <p>thanks for the help</p>