> On 8 May 2021, at 5:32 pm, Alex Zavatone <z...@mac.com> wrote: > > Well, what I’m not sure about are how to store the results internally. Do I > declare both an NSArray and an NSDictionary and check to see which one ended > up getting the proper result?
Call -[propertyListWithData:options:format:error:], and examine what kind of object it returns. Process or store it accordingly. > Is there a class of object that is a collection that is - either an array or > dictionary? Of course, that’s what a collection is, but I’ve never come > across needing to structure code to handle ether an array or a dictionary. It sounds like you might need to rethink your data model a bit. I mean, you could hold the object in a variable of type `id` or `AnyObject` (ObjC or Swift, accordingly), but that will just create hassles for consumers. What format makes the most sense for the model? Transform the other one into it if needed. > + (NSData *)dataWithPropertyList:(id)plist > > OK. So once I get an NSData object, then I need to decode it and see if it’s > an array or dictionary, which ends up being the same problem I already have. No, you have it backwards. That method is useful if you want to create a plist file out of an array, dictionary, etc. To do the opposite, use propertyListWithData:…. b _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com