I am trying to insert an object to an array of NSDictionary but cant find out how. all the examples show how to insert to an array with NSDictionary with insertObject:atIndex, but this one doesnt insert the object under a dictionary key.
My array right now is the following:
NSArray *aaa = [NSArray arrayWithObjects:@"Disable" ,nil];
NSDictionary *aaaDict = [NSDictionary dictionaryWithObject:aaa forKey:@"Computers"];
NSArray *bbb = [NSArray arrayWithObjects:@"Enable", nil];
NSDictionary *bbbDict = [NSDictionary dictionaryWithObject:bbb forKey:@"Computers"];
NSArray *ccc = [NSArray arrayWithObjects:@"Enable", nil];
NSDictionary *cccDict = [NSDictionary dictionaryWithObject:ccc forKey:@"Computers"];
[listOfItems addObject:aaaDict];
[listOfItems addObject:bbbDict];
[listOfItems addObject:cccDict];
I would like to do this, but with a key "Computers":
NSArray *ar = [NSArray arrayWithObjects:@"xxxx", @"yyyy", @"zzzz", nil];
NSDictionary *arDict = [NSDictionary dictionaryWithObject:ar forKey:@"Computers"];
[listOfItems insertObject:ar atIndex:1];
Again - it does add the new array but not under the key "Computers". What am I missing here?
Thanks!
listOfItems, which is presumably anNSArray, doesn't have any concept of keys (it's not a dictionary).