Re: NSDictionary crash
Re: NSDictionary crash
- Subject: Re: NSDictionary crash
- From: Kyle Sluder <email@hidden>
- Date: Sat, 25 Jul 2009 12:39:38 -0700
On Jul 25, 2009, at 12:25 PM, "email@hidden" <email@hidden
> wrote:
You mean because it might be rewritten or corrupted while my app is
reading it, or because the format might change in the future?
I was referring to the latter. Of course you've already noted the
former.
Yes, but then iTunes would have to be running. Plus it's a lot slower.
I believe the sole purpose of the xml file (as opposed to the actual
iTunes library file) is for third parties to be able to access iTunes
data without querying iTunes.app.
Unfortunately the XML file is an implementation detail on whichbwe
cannot rely. It would be nice if Apple opened their iLife framework
for us to use for this purpose -- file a Radar and/or contact DTS.
It's a known issue, but it helps to let Apple know that yet another
developer has encountered this problem.
If I get the data with e g NSData's initWithContentsOfFile:, how would
I initialize the dictionary? I don't see any dictionaryWithData: or
suchlike in NSDictionary. Would I have to do the parsing myself?
As I mentioned, look at NSPropertyListSerialization. NSDictionary is a
plist type and can be decoded from an NSData.
Also, is the NSData equivalent any safer than NSDictionary's? It's
initWithContentsOfFile: method is documented to return "An initialized
object—which might be different than the original receiver—that
contains the dictionary at path, or nil if there is a file error or if
the contents of the file are an invalid representation of a
dictionary." There's no mention of a potential crash. Should I file a
bug?
You can ensure the safety of the file before using NSData. You can't
when using NSDictionary's convenience constructor.
One issue that you will encounter, however, is that iTunes is
incredibly picky about its file store. It will throw a tantrum if it
can't write to its database.
The best answer at the moment is to file a Radar and use Apple Events.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden