を探していたインデックスを持っ
for(int i=0; i<[self.userArray count]; i++) {
NSString *user = [self.userArray objectAtIndex:i];
NSLog(@"%@", user);
}
を使用しました。もう一つの選択肢は、NSArrayのブロックベースの列挙メソッドを利用することです。ブロックベースのメソッドを使用すると、開発中のプラットフォームで並行性を活用でき、将来の方法になります。次のように私は考えていた方法は次のとおりです。
- (NSUInteger)indexOfObjectWithOptions:(BOOL(^)(IDのOBJ、NSUInteger idxを、BOOL *ストップ))述語
:(NSEnumerationOptions)はpassingTest付き合えまた、ここで説明
NSUInteger theIndex=NSNotFound;
theIndex=[theArray indexOfObjectWithOptions:NSEnumerationConcurrent passingTest:^(id obj, NSUInteger, idx, BOOL *stop){
if ([obj rangeOfString: aString]!=NSNotFound]){
*stop=YES;
return YES;
}
return NO;
}];
ソリューション:How to check if an NSString contains one of the NSStrings in an NSArray?
幸運はそうあなたの状況に次のものを使用することができます
見つかった結果のインデックスを知る方法はありますか? – pmerino