• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString propertyList crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString propertyList crash


  • Subject: Re: NSString propertyList crash
  • From: Andy Lee <email@hidden>
  • Date: Sun, 19 Mar 2006 23:31:18 -0500

On Mar 19, 2006, at 11:01 PM, Greg Herlihy wrote:
There is no bug here: an NSDictionary object cannot be initialized with a
binary plist file.

Are you sure? It certainly worked in this case, or so my debugger tells me, but maybe the file I gave it just happened to work. Also, I'm running Tiger 10.4.5 -- does your statement apply to earlier OS versions?


In any case, your code below certainly avoids any chance of encountering the problem.

I would still claim there is a bug, because according to the docs, - [NSDictionary description] and -[NSString propertyList] should convert between string and dictionary representations, and I can create a trivial case where that is not true:


NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: [NSDate date], @"today", nil]; NSString *desc = [dict description]; NSDictionary *newDict = [desc propertyList]; // throws exception


--Andy


For that reason, I would use NSPropertyListSerialization to create an NSDictionary from a plist, since it understands the various plist file formats:

NSString *dirPath = [@"~/Library/Preferences/ com.apple.Bluetooth.plist"
stringByExpandingTildeInPath];
NSData *contents = [NSData dataWithContentsOfFile:dirPath];
NSString *errorString;
NSPropertyListFormat format;


NSDictionary *dict = [NSPropertyListSerialization
propertyListFromData:contents
mutabilityOption:NSPropertyListImmutable format:&format
errorDescription:&errorString];


Greg

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSString propertyList crash
      • From: Tito Ciuro <email@hidden>
References: 
 >Re: NSString propertyList crash (From: Greg Herlihy <email@hidden>)

  • Prev by Date: How to Display Simplified Print Panel
  • Next by Date: Re: How to Display Simplified Print Panel
  • Previous by thread: Re: NSString propertyList crash
  • Next by thread: Re: NSString propertyList crash
  • Index(es):
    • Date
    • Thread