seems like the issues was in this loop:
if ([ability.uid isEqualToNumber: uid]) {
[commander.abilitiesArray addObject:ability];
}
once i have find a match for commander's ability in the list of all abilities, I don't need to check for that ability to match with rest of the abilities, so I added a break statement.
if ([ability.uid isEqualToNumber: uid]) {
//NSLog(@"Adding abilty %@ to commander %@: ",ability.name, commander.name);
[commander.abilitiesArray addObject:ability];
//NSLog(@"Current commander abilty array is %@: ",commander.abilitiesArray);
break;
}
I also added this to the code to make it run on background thread, bringing the launch time down from 6 s to .5 second.
-(instancetype)init {
self = [super init];
if(self) {
[self performSelectorInBackground:@selector(loadCommandersAndAbilities) withObject:nil];
//[self loadCommandersAndAbilities];
// NSOperationQueue
}
return self;
}
loadCommandersAndAbilities: is the method listed in the original question, I also added notifications to let my view controller know when the method has finished.
//end of loadCommandersAndAbilities
[[NSNotificationCenter defaultCenter] postNotificationName:@"TableViewDataDownloaded" object:nil];