Any one please answer me, how to write into the plist file which is located in my resource folder. Please write an example code for me.
+6
A:
You can't. The application bundle is not writable on iPhone OS devices.
Ole Begemann
2010-03-19 17:03:19
A:
Please read the Commonly Used Directories from the iPhone Programming Guide.
epatel
2010-03-21 14:20:38
+1
A:
-(IBAction)textFieldCheck:(id) sender {
myPrimaryinfo = [[NSMutableArray arrayWithCapacity:6]retain];
NSArray *keys = [NSArray arrayWithObjects:@"Date",@"Time",@"Address",@"City",@"State",@"Zipcode",nil];
[myPrimaryinfo addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:
[NSString stringWithFormat:@"%@",txtDate.text],
[NSString stringWithFormat:@"%@",txtTime.text],
[NSString stringWithFormat:@"%@",txtAddress.text],
[NSString stringWithFormat:@"%@",txtCity.text],
[NSString stringWithFormat:@"%@",txtState.text],
[NSString stringWithFormat:@"%@",txtZip.text],nil]forKeys:keys]];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myPrimaryinfo.plist"];
[myPrimaryinfo writeToFile:path atomically:NO];
NSLog(@"PrimaryInfo array: %@", myPrimaryinfo);
}