title: How to edit a plist programmatically?
body: <p>I have a code to edit a plist file. But when the code runs, it changes the plist file but it deletes some other dictionaries. You can look at the images to see what I mean.</p>
  
  <p>To see the edited word, look at dictionary "item 1" and at string "name". You will see that it needs to change from "Second" to "newVALUE".</p>
  
  <p>The <strong><em>original plist</em></strong> is the image of the plist when the plist was created.
  Then you have the <strong><em>expected plist</em></strong> which is what the plist should look like. And the <strong><em>edited plist</em></strong> is the plist after the code was applied.</p>
  
  <p><strong>This is the code:</strong></p>
  
  <pre><code>NSString *plistPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
  plistPath = [plistPath stringByAppendingPathComponent:@"PassaveData.plist"];
  
  NSMutableArray*  newContent = [[NSMutableArray alloc]initWithContentsOfFile:plistPath];
  NSMutableDictionary *Dict = [[NSMutableDictionary alloc]initWithDictionary:[newContent objectAtIndex:1]];
  [Dict setValue:@"newVALUE" forKey:@"name"];
  [Dict writeToFile:plistPath atomically:YES];
  </code></pre>
  
  <p><strong>These are the images</strong></p>
  
  <p><a href="http://i.stack.imgur.com/tCugJ.png" rel="nofollow">Click to see the images</a></p>