Accessing CFBundleTypeExtensions Array in Program?

Discussion in 'Mac Programming' started by MorphingDragon, Jul 14, 2010.

  1. MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #1
    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"];
    
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    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;
     
  4. MorphingDragon thread starter macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #4
    Changed it to objectForKey, works fine now.

    Thanks.

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


    Man, now you made me want lunch.
     

Share This Page