How to read all NSDictionary objects for a key to an array


I have a dictionary "playerDict" that reads data from plist, where there are names (myKey) with nine objects associated with each key.

I am trying to read all objects for a specific key (myKeys) in NSMutableArray (theObjects). I read the link to the class and search on the Internet, but I can not understand our this, possibly very simple problem.

Among all the other tests that I did, I tried the following, but it returns the key in objects, not objects.

theObjects = [playerDict objectForKey: myKeys];

Anyone who can give a hint?

Here is the code that dict created, I split it:

NSArray *objs = [NSArray arrayWithObjects:[NSNumber numberWithBool:playerObject.diffHard],[NSNumber numberWithBool:playerObject.diffMedium],
             [NSNumber numberWithBool:playerObject.diffEasy],[NSNumber numberWithBool:playerObject.currentGame],
             [NSNumber numberWithInt:playerObject.currentGameQuestion],[NSNumber numberWithInt:playerObject.currentGameRightAnswer],
             [NSNumber numberWithInt:playerObject.currentGameType],[NSNumber numberWithInt:playerObject.nrOfType0Games],
             [NSNumber numberWithInt:playerObject.type0Result], nil];
NSDictionary *newPlayerDict = [NSDictionary dictionaryWithObjectsAndKeys:objs, keyString, nil];
+3
source share
2 answers

ForKey:

+4

NSDictionary. , NSArray ( NSSet), .

, , .

: , . :

NSArray *myObjs=[playerDict objectForKey:keyString];

. :

BOOL diffHard=[[myObjs objectAtIndex:0] boolValue];
BOOL diffMedium=[[myObjs objectAtIndex:1] boolValue];

, . .

0

Source: https://habr.com/ru/post/1777178/


All Articles