I have an NSArrayController filled with NSMutableDictionary objects. The following code is working without any problem but I would like to get rid of the compiler warning I get. Collection expression type 'NSManagedObject *' may not respond to 'countByEnumeratingWithState:onjects:count:'
As far as I understand, I get this error because the array controller COULD have also different types of objects inside that do not have a key value. But in my case I am only using mutable dictionaries so it should be ok.
Here is my code:
- (IBAction)getlist:(id)sender{
checkedchecks = 0;
for (NSManagedObject *a in imagescontroller.arrangedObjects)
{
for (NSString* key in a) {
if ([[NSString stringWithFormat:@"%@",[a valueForKey:key]] isEqualToString: @"1"])
{
checkedchecks += 1;
}
}
}
NSAlert *alert = [[NSAlert alloc] init] ;
[alert setMessageText:[NSString stringWithFormat:@"%ld",(long)checkedchecks ]];
[alert runModal];
}
How could i get rid of this annoying warning?
Why are you typing
aas anNSManagedObject *if it’s anNSMutableDictionary *?is probably what you want.