On Oct 13, 2009, at 2:43 PM, DKJ wrote:
I'm using this code to read an array from a plist:
NSArray *data = [NSArray arrayWithContentsOfFile:[NSHomeDirectory()
stringByAppendingPathComponent:@"/Documents/file.plist"]];
The docs say this method returns nil when the file doesn't exist
(precisely: "Returns nil if the file can’t be opened..."). But the
above code gives me an empty array instead, which caused some
confusion.
Surely the docs can't be wrong...
Nope. The docs are correct and I'm betting the file you specified
in fact *doesn't* exist.
"/Documents/file.plist" is probably not a valid path. You probably
meant "~/Documents/file.plist", but that string isn't a valid path
either. Use the appropriate path-manipulating NSString methods to
expand the tilde to a full "/Users/someuser/..." path.
I'll bet that fixes things.
--
I.S.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com