Folks, I'm trying to do the following. I've got a array (NSArray) called 'specialLevels', that array looks like this:
specialLevels = @[@2, @4, @6, @9];
This should be a array of int's. I also got the int 'currentLevel' (basic int no object).
And I want to check if the currentLevel is in de array of specialLevels. I know the method 'containsObject' exists, but this won't work in my case.
What would you guys recommend to do in this case?
So I thought this, but it feels kinda strange imo:
if ([specialLevels containsObject:[NSNumber numberWithInt:currentLevel]]) {
// other code in here
}
You could alternatively write:
if ([specialLevels containsObject:@(currentLevel)]) {
// other code in here
}
which is more in keeping with the style of your other code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With