How to write data in plist file in iphone development

NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:2];NSString *name;

NSDictionary *innerDict;

NSDate *dob;

NSArray *scores;

scores = [NSArray arrayWithObjects:[NSNumber numberWithInt:6],

[NSNumber numberWithFloat:4.6], [NSNumber numberWithLong:6.0000034], nil];

name = @”George Washington”;

dob = [NSDate dateWithString:@”1732-02-17 04:32:00 +0300"];

innerDict = [N[NSDictionary dictionaryWithObjects:

[NSArray arrayWithObjects: name, dob, scores, nil]p>

forKeys:[N[NSArray arrayWithObjects:@”Name”, @”DOB”, @”Scores”]

[r[rootObj setObject:innerDict forKey:@”Washington”]/p>

scores = [N[NSArray arrayWithObjects:[NSNumber numberWithInt:8]br> [N[NSNumber numberWithFloat:4.9]br> [N[NSNumber numberWithLong:9.003433]nil];
name = @”Abraham Lincoln”;
dob = [N[NSDate dateWithString:@”1809-02-12 13:18:00 +0400"]/p>

innerDict = [NSD[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects: name, dob, scores, nil] forKeys:[NSA[NSArray arrayWithObjects:@”Name”, @”DOB”, @”Scores”]r> [roo[rootObj setObject:innerDict forKey:@”Lincoln”]> id plist = [NSP[NSPropertyListSerialization dataFromPropertyList:(id)rootObj
format:NSPropertyListXMLFormat_v1_0 errorDescription:&error]>

Go through this Link to APPLE’s Documentation  For More Info



Leave a Reply

Your email address will not be published. Required fields are marked *