Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MorphingDragon

macrumors 603
Original poster
Mar 27, 2009
5,159
6
The World Inbetween
I can't figure out the code to get this to work. I want to retrieve the supported extensions array from info.plist.

Code:
[[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDocumentTypes"] objectAtIndex:0] objectForInfoDictionaryKey:@"CFBundleTypeExtensions"];
 
objectForInfoDictionaryKey is only available for NSBundle, so you should have gotten an error with the 2nd use of it. Did you check to see what object is being returned from objectAtIndex ?

It'd help to post: any errors, what you're expecting, what you're seeing.
 
What error or warning messages are you getting, if any? I can guess, but it's better if you tell us.

Also note that objectForInfoDictionaryKey: is an NSBundle message. It returns an NSArray (typed as id), which you are correctly using objectAtIndex on. Thereafter, you are incorrectly using objectForInfoDictionaryKey (an NSBundle message, remember), when I think you want objectForKey (an NSDictionary message). Too much copy-pasta?


BTW, I think this is invalid Objective-C syntax in your sig:
Code:
[myCake tasty] = YES;
 
objectForInfoDictionaryKey is only available for NSBundle, so you should have gotten an error with the 2nd use of it. Did you check to see what object is being returned from objectAtIndex ?

It'd help to post: any errors, what you're expecting, what you're seeing.

Changed it to objectForKey, works fine now.

Thanks.

Oddly enough, it didn't error, or even a warning.


Too much copy-pasta

Man, now you made me want lunch.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.