Friday, 15 January 2010

swift - Sharing NSUserDefaults plist file? -


I want to use the facilities of NSUserDefaults to save the state. I am currently working. But I want to copy this plist file and want to apply it to the same app on another device.

Is there a way to pass a file name for NSUserDefaults or do I need to use another category? Or is it ok to share the same app with the other device?

The app on Device 1 and Device 2 is the only app I'm not trying to share data between different applications.

?

NSDictionary * dict = [[NSUserDefaults standard user default] dictionary report];

Then on another device:

  NSUserDefaults * defaults = [NSUserDefaults StandardUserDefaults]; (Copy dictionary in NSString * key) {ID of OB = Dictionary [key]; [Default set object: for ob: key]; }  

Or, you can write a .olist to a .plist file, from that to Transport, .plist Decode to dict and like I did the above.

Write in a .plist file:

  [dict tofile: @ "path / to / your / file.plast" atomically : Yes]; Reading from a  .plist  file: 

  NSDictionary * dict = [[NSDictionary alloc] initWithContentsOfFile: @ "Path / / To your / file.plist "];  

No comments:

Post a Comment