• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: objectForKey
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objectForKey


  • Subject: Re: objectForKey
  • From: stephane sudre <email@hidden>
  • Date: Fri, 15 Oct 2004 17:47:55 +0200


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);

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >objectForKey (From: Martha Espinosa <email@hidden>)

  • Prev by Date: objectForKey
  • Next by Date: Obtaining port from NSSocketPort
  • Previous by thread: objectForKey
  • Next by thread: Re: objectForKey
  • Index(es):
    • Date
    • Thread