Writing to plists located at resource folder in iPhone
Any one please answer me, how to write into the plist fi开发者_JAVA技巧le which is located in my resource folder. Please write an example code for me.
You can't. The application bundle is not writable on iPhone OS devices.
-(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);
}
精彩评论