The task looks to be simple: to check if element is of type Class, but I don't get how. What I have is an array with different data. For example:
NSArray *arr = @[@"name", [NSArray class]];
NSLog(@"type:%@", [arr elementByClass:[Class class]]); //expecting here "type:NSArray"
I need to get first element with custom class. So here's my NSArray category method:
- (id)elementByClass:(Class)elementClass {
for (id obj in self) {
if([obj isKindOfClass:elementClass]){
return obj;
}
}
return nil;
}
though it doesn't compile and fails with error:
"receiver type 'Class' is not an Objective-C class"