开发者

Writing to plists located at resource folder in iPhone

开发者 https://www.devze.com 2022-12-24 01:26 出处:网络
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

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); 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号