Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Ben Kennedy via Cocoa-dev
> On 9 May 2021, at 2:29 pm, Alex Zavatone wrote: > >> It sounds like you might need to rethink your data model a bit. > > That’s what I’m trying to do! : D I meant the internal data model, as in how your program represents the data in memory and in respect of what API it provides to its

Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Alex Zavatone via Cocoa-dev
This little write up might be a fun read. Hey, it’s Sunday. Why not? > On May 9, 2021, at 4:27 PM, Sandor Szatmari > wrote: > > Alex, > >> On May 9, 2021, at 15:15, Steve Mykytyn via Cocoa-dev >> wrote: >> >> You're creating your own problem here. > > Agreed, If you have control. I

Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Alex Zavatone via Cocoa-dev
> On May 9, 2021, at 2:15 PM, Steve Mykytyn wrote: > > You're creating your own problem here. If you are controlling what the > configuration plist is, make it a dictionary at the top level with three keys > and entries: Yup. I sure am. Creating it because I want to solve it. It’s a

Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Alex Zavatone via Cocoa-dev
> On May 8, 2021, at 9:55 PM, Gerd Knops wrote: > > NSPropertyListSerialization returns an id. > > From there you can do > > if([object isKindOfClass:NSArray.class]) > { > NSArray *array=object; // Not really needed, but gives hints to the > compiler > ... > } > else if([object

Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Alex Zavatone via Cocoa-dev
> On May 8, 2021, at 7:42 PM, Ben Kennedy wrote: > > >> On 8 May 2021, at 5:32 pm, Alex Zavatone 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

Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Sandor Szatmari via Cocoa-dev
Alex, > On May 9, 2021, at 15:15, Steve Mykytyn via Cocoa-dev > wrote: > > You're creating your own problem here. Agreed, If you have control. I would either make all top level objects arrays, or dictionaries. If your writing the plist and its a dict, wrap it in an array, or vice versa,

Re: How do you handle reading a plist if it may be an array or a dictionary?

2021-05-09 Thread Steve Mykytyn via Cocoa-dev
You're creating your own problem here. If you are controlling what the configuration plist is, make it a dictionary at the top level with three keys and entries: idString - something that confirms to you that this is one of yours array - the array you want in some cases dictionary - the