I want to get value from NSDictionary
. I want to control "Code" key according to Code key, I will get datum values. I get error message When I try different methods.
ERROR MESSAGE
2011-08-11 12:45:21.549 AOK[6312:207] -[__NSArrayM
getObjects:andKeys:]: unrecognized selector sent to instance 0x5e138b0
2011-08-11 12:45:21.550 AOK[6312:207] * Terminating app due to
uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM
getObjects:andKeys:]: unrecognized selector sent to instance
0x5e138b0'
* Call stack at first throw:
NSDictionary
(
{
Omschrijving = "ADDD";
Ophaaldata = {
Datum = (
"2011-07-04",
"2011-07-11",
"2011-07-18",
"2011-07-25"
);
};
},
{
Omschrijving = "BBBB";
Ophaaldata = {
Datum = (
"2011-07-05",
"2011-07-12",
"2011-07-19",
"2011-07-26"
);
};
},
{
Omschrijving = "KKKK";
Ophaaldata = {
Datum = (
"2011-07-07",
"2011-07-14",
"2011-07-21",
"2011-07-28"
);
};
},
{
Omschrijving = "LLLLL";
Ophaaldata = {
Datum = (
"2011-07-01",
"2011-07-08",
"2011-07-15",
"2011-07-22",
"2011-07-29"
);
};
},
{
Omschrijving = "MMMMM";
Ophaaldata = {
Datum = (
"2011-07-01",
"2011-07-15",
"2011-07-29"
);
};
},
{
Code = POP;
Omschrijving = "FFFF";
Ophaaldata = {
Datum = "2011-07-12";
};
},
{
Code = 00;
Omschrijving = "SSSS";
Ophaaldata = {
Datum = (
"2011-07-14",
"2011-07-27"
);
};
},
{
Code = 01;
Omschrijving = "CCCCC";
Ophaaldata = {
Datum = (
"2011-07-06",
"2011-07-20"
);
};
}
)
Best Answer
What you display is an NSArray of NSDictionaries, each containing an NSString with the description (Omschrijving) and an NSDictionary (Ophaaldata) with one key (Datum), which is an array of dates. If you send
Objects:andKeys:
to an NSArray, it won't work.These are a few examples of how you can get at the individual items:
These are only examples of how you can address the items. But this is the structure your output shows. Anything else would be useless, anyway, since a dictionary can only contain each key once. I formatted the code a little, so you can see the structure a bit better.