Dar*_*ren 0 xcode cocoa-touch objective-c nsarray
举个例子,如果我有这个数组:
_mode = [NSArray arrayWithObjects:
[NSArray arrayWithObjects:@"1", @"One", nil],
[NSArray arrayWithObjects:@"2", @"Two", nil],
[NSArray arrayWithObjects:@"3", @"Three", nil],
[NSArray arrayWithObjects:@"4", @"Four", nil],
[NSArray arrayWithObjects:@"5", @"Five", nil],
nil];
Run Code Online (Sandbox Code Playgroud)
我需要找到数组_mode的哪个对象包含@"3"我该怎么做?我尝试过selectedIndex = [_mode indexOfObject:@"3"];,selectedIndex = [[_mode objectAtIndex:0] indexOfObject:@"sta"];但都没有工作.
[_mode indexOfObjectPassingTest:^(id obj, NSUInteger idx, BOOL *stop){
return [[obj objectAtIndex:0] isEqualToString:@"3"];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2638 次 |
| 最近记录: |