如何检查一个元素是否存在于数组中
How to check if an element exists in an array
NSInteger indexOfMatchedObject = [self.array indexOfObject:object.objectId];
我需要检查 indexOfMatchedObject
中是否有值,我该怎么做?
使用常量NSNotFound
来确定对象是否存在于数组中。
使用此方法检查数组是否包含值 [self.array containsObject:object.objectId]。这将 return 布尔值。
NSInteger indexOfMatchedObject = [self.array indexOfObject:object.objectId];
我需要检查 indexOfMatchedObject
中是否有值,我该怎么做?
使用常量NSNotFound
来确定对象是否存在于数组中。
使用此方法检查数组是否包含值 [self.array containsObject:object.objectId]。这将 return 布尔值。