I have a NSDictionary
and a NSArray
:
self.dataDic = [[[NSDictionary alloc] init] autorelease];
self.dataDicKey = [[[NSArray alloc] init] autorelease];
These are the key and value of my NSDictionary
:
self.dataDic =
@{@"Ring Cloud" :@[@"Contact Cloud", @"Image Cloud", @"Data Cloud"],
@"Ring Tools" :@[@"Sticker Market", @"Live Poll", @"Mail"],
@"Ring Apps" :@[@"Studio", @"Player"]};
Now what I want is to insert all the key value of my self.dataDic
into self.dataDicKey
sequentially. That means it looks like this:
self.dataDicKey = [[[NSArray alloc] initWithObjects:@"Ring Cloud", @"Ring Tools", @"Ring Apps",nil] autorelease];
I have tried with this:
self.imageDicKey = [[[self.imageDic allKeys] reverseObjectEnumerator] allObjects];
But it's not actually sorted the values. If any one have any suggestion please share it with me.
Thanks a lot in advance.
If you are trying to get the
keys
asobjects
in yourNSArray
you should try this methodOne thing to remember that
NSDictionary
allKeys method returns only the keys regardless of order they were saved. as itsKVP
This will copy your
NSDictionary
keys intoNSArray