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:28:13 +0100
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
[NSDictionary addObject:&myClass forKey:[NSNumber numberWithInteger:1]]
or NSDictionary in combination with some struct.
[NSDictionary addObject:&myStruct forKey:[NSNumber numberWithInteger:1]]
but I would like to know whether exist any more elegant solution ...
Donald
On Feb 26, 2010, at 0:12 , Greg Parker wrote:
On Feb 25, 2010, at 2:59 PM, Dave Carrigan wrote:
On Feb 25, 2010, at 2:51 PM, Daniel Káčer wrote:
i need help with solution about store more complex values into
NSDictionary.
I have following data which i need store in NSDictionary:
value1:@"A1" value2:@"B1" key:1
value1:@"A2" value2:@"B2" key:2
value1:@"A3" value2:@"B3" key:3
etc.
What is the ideal solution for this my case ?
Create a class to represent your complex values and store instances
of that class in the dictionary.
Another option: put the values in some container (array or set or
dictionary), and set the container as the dictionary's value. This is
how plists and user defaults work. It does get messy fast, though, in
which case you want the more rigid structure of a real class.
--
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