Here is the method how to read or write in plist file in iphone development
-(void)writeToPlist:(NSString *)User_Id
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];
NSMutableDictionary *UserData = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
[UserData setObject:User_Id forKey:@"CustomerId"];
[UserData writeToFile:path atomically:YES];
[UserData release];
}
-(NSString *)ReadFromPlist
{
NSString* path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];
NSMutableDictionary *UserData = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
return [UserData valueForKey:@"CustomerId"];
[UserData release];
}
2 comments:
Does not work
Hi I have written a PlistManager file that makes using plist files in swift easy: http://rebeloper.com/read-write-plist-file-swift/ Full step by step tutorial with lots of images.
Post a Comment