我正在过滤一个NSMutableArray
来获取一个对象(NSDictionary
),然后我想获取这个对象在原始NSMutableArray
中的索引。但不知何故,当该数组中只有 5 个项目时,给出的索引是 2147483647
。
有人能指出我如何获得原始数组中获取的对象的索引吗?
predicate = [NSPredicate predicateWithFormat:@"data.resourceID == %@",addEvents[@"resourceID"]];
result = [appDataMutable filteredArrayUsingPredicate:predicate];
NSLog(@"%i",[appDataMutable indexOfObject:result]);
//...
[appDataMutable replaceObjectAtIndex:[appDataMutable indexOfObject:result] withObject:resultDictionary]'
最佳答案
当在数组中找不到对象时,indexOfObject:
returns NSNotFound
,定义为
enum {NSNotFound = NSIntegerMax};
NSIntegerMax
为 0x7fffffff
,即 2147483647。
关于objective-c - 在通过谓词获取 NSArray 后,如何获取其父 NSMutableArray 中的 NSArray 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19199812/