Skip navigation.
 
mlRe: objectForKey
FROM : stephane sudre
DATE : Fri Oct 15 17:47:55 2004

On Oct 15, 2004, at 5:41 PM, Martha Espinosa wrote:

> Hi,
>
> In my project I have a dictionary with the following...
>
> 2004-10-15 09:18:17.213 Dynamic[1814] Item 1: <CFDictionary 0x341850
> [0xa01900e0]>{type = mutable, count = 5, capacity = 8, pairs = (
>         2 : package = <CFString 0x3417d0 [0xa01900e0]>{contents =
> "package"}
>         3 : other = <CFString 0x341800 [0xa01900e0]>{contents = "YES"}
>         4 : name = <CFString 0x341740 [0xa01900e0]>{contents = " name"}
>         6 : esdname = <CFString 0x341760 [0xa01900e0]>{contents =
> "Mac"}
>         10 : install = <CFString 0x341700 [0xa01900e0]>{contents = "Y"}
> )}
> 2004-10-15 09:18:17.214 Dynamic[1814] Item 2: <CFDictionary 0x341ac0
> [0xa01900e0]>{type = mutable, count = 5, capacity = 8, pairs = (
>         2 : package = <CFString 0x341a70 [0xa01900e0]>{contents =
> "package"}
>         3 : other = <CFString 0x341aa0 [0xa01900e0]>{contents = "YES"}
>         4 : name = <CFString 0x3419c0 [0xa01900e0]>{contents = " Name"}
>         6 : esdname = <CFString 0x341a00 [0xa01900e0]>{contents =
> "Mac/"}
>         10 : install = <CFString 0x341980 [0xa01900e0]>{contents = "N"}
> )}
>
> How do I just grab one of the items from within this dictionary for
> every item?  I tried using [software objectForKey:@"install"] without
> success...
>
>         int i, count;
>         count = [software count];
>         for (i = 0; i < count; i++)
>              {
>                        NSString *item=[software objectAtIndex:i];
>                       NSLog (@"Item %d: %@", i, item);
>                 }
>
> any help will be appreciated.


If the idea is to get an array of the values:

int i, count;
NSMutableArray * tMutableArray;

count = [software count];

tMutableArray=[NSMutableArray arrayWithCapcity:count];

for (i = 0; i < count; i++)
{
   NSDictionary * tDictionary=[software objectAtIndex:i];
    
   [tMutableArray addObject:[tDictionary objectForKey:@"install"]];
}

NSLog(@"%@", tMutableArray);

Related mailsAuthorDate
mlobjectForKey Martha Espinosa Oct 15, 17:41
mlRe: objectForKey stephane sudre Oct 15, 17:47
mlRe: objectForKey Dustin Voss Oct 15, 21:30
mlRe: objectForKey Scott Stevenson Oct 16, 01:15