I am trying to save some elements in pList . Here is the array loop:
for (id obj in items) NSLog(@"obj: %@", obj);
NSLog Output:
2013-03-27 13:00:40.072 mycode[47436:c07] obj: Red 2013-03-27 13:00:40.073 mycode[47436:c07] obj: Blue 2013-03-27 13:00:40.073 mycode[47436:c07] obj: Green
// The arrayWithObjects array works. But I donβt know how to (loop?) Through my objects save to a plist file ...
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"data.plist"]; NSFileManager *filemgr; filemgr = [NSFileManager defaultManager]; if ([filemgr fileExistsAtPath: path]) { NSLog(@"%@", path); NSMutableDictionary *plist = [[NSDictionary dictionaryWithContentsOfFile:path] mutableCopy]; NSMutableArray *newArray = [[[NSMutableArray alloc] init] autorelease]; newArray = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue" nil];
source share