I have something like this:
@interface Person : NSObject
{
NSString *fname;
NSString *lname;
}
NSString *keys = @"a","a","b","b","b"....";
for(NSString *key in keys)
{
Person *newPerson; //alloc new person
[myMutableDictionary setValue:newPerson forKey:key];
}
The above code will override the value with same key since NSDictionary doesn’t allow duplicate keys. How can I do this?
I can do the above code by NSMutableArray, as in [array addObject:newPerson]; but it takes longer to fetch for (Key,value) as opposed to NSDictionary? My data is about 400,000 items, Any idea on how to do this efficiently? I need to load it once and do many fetches on it – No coreData, I tried it, its slow.
If you use an
NSMutableArrayas a key you can add multiplePersonobjects for the same key.