Array of NSDictionaries

Discussion in 'Mac Programming' started by BollywooD, Oct 2, 2009.

  1. BollywooD macrumors 6502

    BollywooD

    Joined:
    Apr 27, 2005
    Location:
    Surfers Paradise
    #1
    so I have an NSArray of NSDictionaries, and I would like to return an NSArray of keys from these dictionaries.


    where do I start?
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    Do all of the dictionaries have the same keys? If so, just get the first element of the NSArray, and get the keys of the NSDictionary using allKeys. If not, for each array element get the keys and append them to an NSMutableArray with addObjectsFromArray.

    -Lee
     
  3. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #3
    NSDictionary has a method allKeys: and then you can combine the arrays using NSMutableArray's addObjectsFromArray:
     
  4. BollywooD thread starter macrumors 6502

    BollywooD

    Joined:
    Apr 27, 2005
    Location:
    Surfers Paradise

Share This Page