> On May 8, 2021, at 7:42 PM, Ben Kennedy <b...@zygoat.ca> wrote:
> 
> 
>> 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.

That’s what I’m trying to do!  : D

> 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.

That’s what I was trying to avoid.  I’d simply like to see if there is a better 
way, but it might be OK to bring it in as id, check the class and then save as 
either dictionary or array.  Once it’s read only once it’s in.  

This might be a fun case for a dict or array wrapper class for my dict or array 
plist reader thanks to your tips. 

> 
>> + (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:….
> 

Huh? + (NSData *)dataWithPropertyList:(id)plist returns an NSData object.  
Isn’t the propertyListWithData the one that creates a property list out of 
NSData?  

Anyway, thanks man!  Good stuff.

Thanks and happy Sunday.  

Alex Zavatone.
_______________________________________________

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

Reply via email to