I’m having troubles checking if an array contains an object.
The @property(nonatomic) NSArray<NSNumber*>* apiArray;
array is returned as a parameter from an API model while the object of which I want to check the presence in the array is returned from another API model @property(nonatomic) NSNumber* localObject;
.
When I check for it [apiArray containsObject: localObject]
it outputs 0 even though the value is there..
So I checked the types and on localObject
the type is effectively an NSNumber, while If i’m not mistaking the array results being an NSString array as by the prints below.
NSLog(@"$$$$$$$$$$$ [apiArray containsObject: localObject]: %d", [apiArray containsObject: localObject] );
NSLog(@"apiArray types are: %@", [apiArray valueForKey:@"class"]);
NSLog(@"localObject type is: %@", [localObject valueForKey:@"class"]);
$$$$$$$$$$$ [apiArray containsObject: localObject]: 0
apiArray types are: (
"__NSCFString"
)
localObject type is: __NSCFNumber
The models are generated via swagger-codegen.jar but as the parameters are shown they both seem correct.
Can you spot what the problem might be?