New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
iOS Development Discussion on developing apps for the iOS platform.

Key- Value Table help required


Post Reply New Thread Subscribe

 
Thread Tools
sagarshivam

 
Member Since: Jun 03, 2011
Posts: 54
sagarshivam is on a distinguished road

sagarshivam is offline
Hi all!!

I am looking for some data structure which will store data in terms of key and value and where one key corresponds to one or more than one value.

So , something like:

KEY VALUE
key1 value1
key1 value2
key1 value3
key2 value4
key2 value5
...... ..........

and on query all VALUE for a particular KEY is obtained in array.

I tried implementing NSDictionary but I am able to save on one to one basis only Multiple values for one ley is not possible.

Kindly help
QUOTE Thanks
sagarshivam

 
Member Since: Jun 03, 2011
Posts: 54
sagarshivam is on a distinguished road

sagarshivam is offline
or say that I have three keys (string type)like: key1,key2 and key3 and corresponding to each I have three arrays (NSarray type) array1, array2 and array3

So i want to map these as key and values:


key1 ---------> array1
key2----------> array2
key3----------> array3

So that from this structure, whenever VALUE for KEY (say key1) is queried, array1 (and so on) is returned.


Thanks in advance
QUOTE Thanks
Nethfel

 
Member Since: Feb 25, 2009
Posts: 2,088
Nethfel is a glorious beacon of lightNethfel is a glorious beacon of lightNethfel is a glorious beacon of lightNethfel is a glorious beacon of lightNethfel is a glorious beacon of lightNethfel is a glorious beacon of light
Mac Specs: Late 2013 rMBP, i7, 750m gpu, OSX versions 10.9.3, 10.10

Nethfel is offline
If you're doing a single key refers to a single array, you can use an NSDictionary. NSDictionaries can contain NSArrays (or NSMutableArrays) - the problem arises if you want to use a single key to refer to multiple different arrays (which would make sense because then how would you know what array you really wanted?) which technically you still could do - You could have a key reference a mutable array in an ns dictionary, each entry in the mutable array is another array.

So it might look like:
Code:
Dict key1 ------------> Mutable Array of possibles
                                 |----> Mutable array 1
                                 |----> Mutable array 2
                                 |----> Mutable array 3
Dict key2 ------------> Mutable Array of possibles
                                 |----> Mutable array 1
                                 |----> Mutable array 2
                                 |----> Mutable array 3
Dict key3 ------------> Mutable Array of possibles
                                 |----> Mutable array 1
                                 |----> Mutable array 2
                                 |----> Mutable array 3
Of course, the other option is to use an SQLite database or CoreData

My Macs: Late 2013 rMBP w/ 750m; Mac mini G4, 1.25 GHz, 512m ram (server); Late 2011 11" MBA, 1.8GHz i7, 4Gig Ram, 256Gig SSD, HD3000; Powerbook 12" G4 1.33GHz running Debian as a server; Apple TV (1080p version)
QUOTE Thanks
sagarshivam

 
Member Since: Jun 03, 2011
Posts: 54
sagarshivam is on a distinguished road

sagarshivam is offline
Thanks a lot. you always have helped me in trying further with codes.
QUOTE Thanks

Post Reply New Thread Subscribe


« NSXML help required | Value passing problem from once class to another »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Airport on my powerbook won't connect when my WEP key is 64-bit gort Internet, Networking, and Wireless 2 08-21-2010 12:59 PM
IBM External USB Keyboard - No Windows Key - Looking For Shortcut goddess_of_go Switcher Hangout 5 07-03-2008 10:27 PM
Missing Key on UK PowerBook 12 inch Aluminium rudeboymick Apple Notebooks 1 06-08-2008 08:51 PM
mapping caps-lock key to escape key fooboo OS X - Operating System 1 05-12-2008 07:22 PM
mysql "primary key" help funky Web Design and Hosting 4 05-16-2005 09:35 PM

All times are GMT -4. The time now is 10:16 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?