Hi all,
Does anyone know how I can easily check a value inside an integer array?
For example, I have an array filled with 12 integers. During my game I need to
check to see if any one of those integers has been set to a value of 1.
Thanks,
Dan
A fast, easy to use, free, and community supported 2D game engine
Hi all,
Does anyone know how I can easily check a value inside an integer array?
For example, I have an array filled with 12 integers. During my game I need to
check to see if any one of those integers has been set to a value of 1.
Thanks,
Dan
from NSArray
- (NSUInteger)indexOfObject:(id)anObject
Returns the lowest index whose corresponding array value is equal to a given object. hth, Codemattic
Thanks Codemattic, my array is filled with integer primitives but not objects.
Will that be an issue?
dan
Oh sorry, if you mean a c-based array then you have to search it yourself.
I think it's best I use your original suggestion to use an array filled with Integer objects. But how can I 'wrap' a primitive integer value inside an Integer object?
Thanks,
Dan
Not necessarily, if your data is in c then go with that. But if you want to use objective-c objects then use NSNumber's -numberWithInteger: or -numberWithInt:
You must log in to post.