Posted By

espinallab on 02/09/10


Tagged

list save to plist properity


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

shimdh
umang_nine
cnathan


Save to .plist properity list


 / Published in: Objective C
 

URL: http://www.iphonedevsdk.com/forum/iphone-sdk-development/5823-save-plist-properity-list.html

  1. //What you want to do is write it into your sandbox Documents directory like so:
  2.  
  3. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  4. NSString *documentsDirectory = [paths objectAtIndex:0];
  5. NSString *path = [documentsDirectory stringByAppendingPathComponent:@"patientList.plist"];
  6. [myPatients writeToFile:path atomically:YES];
  7.  
  8.  
  9. //or write it into your sandbox temporary (/tmp) directory like this
  10.  
  11. NSString *path = [NSTemporaryDirectory() stringByAppendingPathComponent:@"patientList.plist"];
  12. [myPatients writeToFile:path atomically:YES];
  13.  
  14.  
  15. Reading it:
  16.  
  17. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  18. NSString *documentsDirectory = [paths objectAtIndex:0];
  19. NSString *path = [documentsDirectory stringByAppendingPathComponent:@"patientList.plist"];
  20.  
  21. contentArray = [NSArray arrayWithContentsOfFile:path ];

Report this snippet  

You need to login to post a comment.