Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to write data in plist?
    text
    copied!<p>I have created save.plist in a resource folder. I have written some data within that directly (without using coding). I am able to read that data but I'm not able to write through code to the same save.plist. By using following code I am trying to write the data but it gets stored within my .app plist. The code is here</p> <pre><code>NSString *errorDesc = nil; NSPropertyListFormat format; NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"save" ofType:@"plist"]; NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath]; NSMutableDictionary *temp = (NSMutableDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&amp;format errorDescription:&amp;errorDesc]; if (!temp) { NSLog(errorDesc); [errorDesc release]; } // [temp setValue:@"123" forKey:@"line1"]; // [temp writeToFile:plistPath atomically: YES]; //Reading data from save.plist NSLog([temp objectForKey:@"name"]); NSLog([temp objectForKey:@"wish"]); NSNumber *num=[temp valueForKey:@"roll"]; int i=[num intValue]; printf("%d",i); //writitng the data in save.plist [temp setValue:@"green" forKey:@"color"]; [temp writeToFile:plistPath atomically: NO]; NSMutableDictionary *temp1 = (NSMutableDictionary *)[NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&amp;format errorDescription:&amp;errorDesc]; NSLog([temp objectForKey:@"color"]); </code></pre> <p>I want that, the data which I want to write should get written into save.plist only which is stored in references. I am new with this concept. So if anyone knows it please help me. Thanks in advance. :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload