Search code examples
iosobjective-cnsarray

How to check if an element exists in an array


NSInteger indexOfMatchedObject = [self.array indexOfObject:object.objectId];

i need to check if there is value in indexOfMatchedObject or not, how can i do this?


Solution

  • Use the constant NSNotFound to determine whether the object was present in the array or not.