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

2021-05-08 Thread Ben Kennedy via Cocoa-dev
> 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 proper result? Call -[propertyListWithData:options:format:error:],

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

2021-05-08 Thread Alex Zavatone via Cocoa-dev
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? Is there a class of object that is a collection that is - either an array or dictionary? Of course, that’s what

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

2021-05-08 Thread Ben Kennedy via Cocoa-dev
Sounds like NSPropertyListSerialization is what you’re after. https://developer.apple.com/documentation/foundation/nspropertylistserialization b Sent from my iPhone > On May 8, 2021, at 5:12 PM, Alex Zavatone via Cocoa-dev > wrote: > > I’m reading a configuration plist like so. > > NSFileM

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

2021-05-08 Thread Alex Zavatone via Cocoa-dev
I’m reading a configuration plist like so. NSFileManager *fileManager = [NSFileManager defaultManager]; BOOL success = [fileManager fileExistsAtPath:filePath]; if (success) { _configurationDictionary = [[NSMutableDictionary alloc]initWithDictionary:[NSDictionary dictionary