开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜