Posted By

saturngod on 12/03/10


Tagged

plist


Versions (?)

Read/ Write Plist


 / Published in: Objective C
 

URL: http://www.ipodtouchfans.com/forums/showthread.php?t=64679

  1. - (void)readPlist
  2. {
  3. NSString *filePath = @"/System/Library/CoreServices/SystemVersion.plist";
  4. NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
  5.  
  6. NSString *value;
  7. value = [plistDict objectForKey:@"ProductVersion"];
  8.  
  9. /* You could now call the string "value" from somewhere to return the value of the string in the .plist specified, for the specified key. */
  10. }
  11.  
  12. - (void)writeToPlist
  13. {
  14. NSString *filePath = @"/System/Library/CoreServices/SystemVersion.plist";
  15. NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
  16.  
  17. [plistDict setValue:@"1.1.1" forKey:@"ProductVersion"];
  18. [plistDict writeToFile:filePath atomically: YES];
  19.  
  20. /* This would change the firmware version in the plist to 1.1.1 by initing the NSDictionary with the plist, then changing the value of the string in the key "ProductVersion" to what you specified */
  21. }

Report this snippet  

You need to login to post a comment.