NSArray* array=@[@"test1",@"test2",@"test3",@"test4",@"test5",@"test6",@"test7"];
NSString* str=[array objectAtIndex:3];
NSLog(@"str=%@",str);
//获取元素所在位置,如果找不到,返回NSNotFound(-1);
NSInteger index=[array indexOfObject:str];
NSLog(@"index=%ld",index);
网友评论