Testing if NSMutableArray contains a string object

后端 未结 5 486
醉酒成梦
醉酒成梦 2021-01-31 14:59

I have a NSMutableArray which contains a few NSString objects. How can I test if the array contains a particular string literal?

I tried

5条回答
  •  梦谈多话
    2021-01-31 15:34

    You may also use a predicate:

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF IN %@", theArray];
    BOOL result = [predicate evaluateWithObject:theString];
    

提交回复
热议问题