user701630
user701630

Reputation: 5

How to store an array into a plist file?

I have an array, and I want to store that array into a plist file. How can I do this?

Upvotes: 0

Views: 2913

Answers (3)

visakh7
visakh7

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

Chirag S
Chirag S

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

Chirag S
Chirag S

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

Related Questions