Reputation: 5
I have an array, and I want to store that array into a plist file. How can I do this?
Upvotes: 0
Views: 2913
Reputation: 26400
Assuming that you have a variable urArray
holding the array and an NSString
variable called pListFilePath
that holds the complete path name of the file you want to create, then this will do it:
[urArray writeToFile:pListFilePath atomically:YES];
Upvotes: 3
Reputation: 364
Follow this steps:for NSArray
store into plist
Example : arrResult
is your array
NSMutableDictionary *dict1=[[NSMutableDictionary alloc]init];
[dict1 setValue:arrResult forKey:@"Result"];
[dict1 writeToFile:[self plistPath] atomically:YES];
[dict1 release];
Upvotes: 2
Reputation: 364
NSMutableDictionary *dict1=[[NSMutableDictionary alloc]init];
[dict1 setValue:txtUserName.text forKey:@"username"];
[dict1 setValue:txtPassword.text forKey:@"password"];
[dict1 writeToFile:[self plistPath] atomically:YES];
[dict1 release];
Upvotes: 1