Re: Store more complex values into NSDictionary
Re: Store more complex values into NSDictionary
- Subject: Re: Store more complex values into NSDictionary
- From: Daniel Káčer <email@hidden>
- Date: Fri, 26 Feb 2010 00:41:13 +0100
thus more to i think over, I start giving you the truth ..
that this solution is basically what I need .. :)
NSDictionary *values = [NSDictionary
dictionaryWithObjectsAndKeys:@"A1", @"subKey1", @"B1", subKey2", nil];
NSDictionary *keyedValues = [NSDictionary
dictionaryWithObjectsAndKeys:values, @"1", nil];
On Feb 26, 2010, at 0:33 , Greg Parker wrote:
On Feb 25, 2010, at 3:25 PM, Daniel Káčer wrote:
Ok, this good idea .. but which container contains 2 values ? ...
Array is one dimensional container, set also one dimensional and
dictionary is key based container .. so value with key ..
there i know only about solution NSDictionary with my custom class
You store multiple values in an array, then store that array in a
dictionary. Basically, you're using an array object instead of an
object of a custom class.
Something like this:
NSArray *array = [NSArray arrayWithObjects:@"MyValue1",
@"MyValue2", nil];
[myDict addObject:array forKey:@"MyKey"];
You'd fetch individual values like this:
NSString *value1 = [[myDict objectForKey:@"MyKey"] objectAtIndex:0];
NSString *value2 = [[myDict objectForKey:@"MyKey"] objectAtIndex:1];
// value1 is @"MyValue1", value2 is @"MyValue2".
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden