I have a function that I use to construct an array by checking if a particular property is equal to a particular value of an object among many in a large data array. The data array is fully initialized, but I cannot retrieve any objects out of it. When I go through the code, XCode tells me that the “thing” variable below is out of scope.
Is this an error due to my function or is the problem with the data array? (I checked the data array independently and it’s got the right count and the right members).
- (NSMutableArray *)parseForProperty:(NSString*)property EqualTo:(NSString*)value
{
NSMutableArray *result = [[NSMutableArray alloc] init];
SEL selector = NSSelectorFromString(property);
NSLog(@"parseProp");
for (RCDetailItem *thing in [[self defaultStore] parsedData])
{
NSLog(@"Thing Title: %@", thing.title);
if ([thing performSelector:selector] == value)
{
[result addObject:thing];
}
}
return result;
}
Currently, you don’t compare Strings but reference.
You can try :
But I’m sure it will resolve because you refer to “variable below is out of scope”. Is it a compile error ?