Re: Enumerating problems
Re: Enumerating problems
- Subject: Re: Enumerating problems
- From: Jonathan Jackel <email@hidden>
- Date: Sat, 4 Oct 2003 10:58:40 -0400
//Typed in Mail. Usual disclaimers apply.
NSEnumerator *eDicts = [MyArray objectEnumerator]; // p.s. Don't
capitalize variable names
NSDictionary *aDict;
while (aDict = [eDicts nextObject])
{
NSString *menuTitle = [aDict objectForKey:@"theOneIWant"];
//set up your menu here
}
You may want to make aDict an id and check for the type of object in
the array if you are not totally sure that every object in the array is
a dictionary.
Jonathan
On Saturday, October 4, 2003, at 10:26 AM, David Dauer wrote:
Hello,
I have an array with an unlimited number of dictionarys.
(e.g. <key>key</key>
<array>
<dict>
<key>theOneIWant</key>
<string>1</string>
<key>theOneIHate</key>
<string>2</string>
</dict>
<dict>
<key>theOneIWant</key>
<string>3</string>
<key>theOneIHate</key>
<string>4</string>
</dict>
</array>)
I load the array
defaults = [NSUserDefaults standardUserDefaults];
MyArray = [[defaults objectForKey:@"key"] retain];
Now I want to create NSMenuItems with the titles "1" and "3" and so on.
My problem is that I don't know how to enumerate through an array
containing
dictionarys and getting everytime a value from the dictionary.
Thanks for any help
--David
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.