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 a collection is, but I’ve never come across needing to structure code to handle ether an array or a dictionary. In the text of the article, “A property list is itself an array or dictionary that contains only NSData <https://developer.apple.com/documentation/foundation/nsdata>, NSString <https://developer.apple.com/documentation/foundation/nsstring>, NSArray <https://developer.apple.com/documentation/foundation/nsarray>, NSDictionary <https://developer.apple.com/documentation/foundation/nsdictionary>, NSDate <https://developer.apple.com/documentation/foundation/nsdate>, and NSNumber <https://developer.apple.com/documentation/foundation/nsnumber> objects.” It seems like just stalling the inevitable. + (NSData <https://developer.apple.com/documentation/foundation/nsdata> *)dataWithPropertyList:(id)plist format:(NSPropertyListFormat <https://developer.apple.com/documentation/foundation/nspropertylistformat>)format options:(NSPropertyListWriteOptions <https://developer.apple.com/documentation/foundation/nspropertylistwriteoptions>)opt error:(out NSError <https://developer.apple.com/documentation/foundation/nserror> * _Nullable *)error; 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. So, what would be the next step after that? Thanks, Ben. Alex Zavatone > On May 8, 2021, at 7:25 PM, Ben Kennedy <b...@zygoat.ca> wrote: > > Sounds like NSPropertyListSerialization is what you’re after. > > https://developer.apple.com/documentation/foundation/nspropertylistserialization > > <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 >> <cocoa-dev@lists.apple.com> wrote: >> >> I’m reading a configuration plist like so. >> >> NSFileManager *fileManager = [NSFileManager defaultManager]; >> BOOL success = [fileManager fileExistsAtPath:filePath]; >> >> if (success) { >> >> _configurationDictionary = [[NSMutableDictionary >> alloc]initWithDictionary:[NSDictionary >> dictionaryWithContentsOfFile:filePath]]; >> >> >> >> >> In some cases, I want the plist to be a dictionary. In others, I want it to >> be an array. >> >> How would anyone recommend to make this a generic method to that could >> handle if the contents of the plist was an array or a dictionary? >> >> Thanks in advance. >> 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