Results 1 to 4 of 4
  1. #1


    Member Since
    Jun 03, 2011
    Posts
    54
    Key- Value Table help required
    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

  2. #2


    Member Since
    Jun 03, 2011
    Posts
    54
    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

  3. #3


    Member Since
    Feb 25, 2009
    Posts
    2,112
    Specs:
    Late 2013 rMBP, i7, 750m gpu, OSX versions 10.9.3, 10.10
    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, 16Gig ram; 2013 Mac Pro 6 core w/ D700, 16Gig Ram; 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 Linux; Apple TV (1080p version)

  4. #4


    Member Since
    Jun 03, 2011
    Posts
    54
    Thanks a lot. you always have helped me in trying further with codes.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I copy table table as plain text?
    By craftydad in forum Switcher Hangout
    Replies: 1
    Last Post: 01-29-2015, 02:27 PM
  2. Shortcut Key: Add Row in Table of WORD
    By simonvee in forum OS X - Apps and Games
    Replies: 2
    Last Post: 06-18-2014, 09:42 AM
  3. Depressing a single keyboard key causes two key strokes to be registered
    By bhamilton in forum Other Hardware and Peripherals
    Replies: 3
    Last Post: 08-13-2012, 05:59 PM
  4. Pages - table within a table?
    By watfordkev in forum OS X - Apps and Games
    Replies: 0
    Last Post: 07-13-2011, 04:08 PM
  5. Question mark key isn't working after taking key off
    By misspeak in forum Apple Notebooks
    Replies: 0
    Last Post: 02-18-2009, 10:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •