0

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

Monolo
  • 18,205
  • 17
  • 69
  • 103
user701630
  • 5
  • 1
  • 3

3 Answers3

3

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];
Monolo
  • 18,205
  • 17
  • 69
  • 103
visakh7
  • 26,380
  • 8
  • 55
  • 69
2

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];
visakh7
  • 26,380
  • 8
  • 55
  • 69
Chirag S
  • 364
  • 3
  • 12
1
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];
NSResponder
  • 16,861
  • 7
  • 32
  • 46
Chirag S
  • 364
  • 3
  • 12