如何指示 NSIndexSet 对象的索引?
每个人。
我想指示 NSIndexSet
对象的索引。
找了各种方法但没找到。
如何指示NSIndexSet
对象的索引?
NSMutableArray *array = [[NSMutableArray alloc]initWithObjects:@"A",@"B",@"C",@"A", nil];
NSIndexSet *indexset = [array indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return [obj isEqual:@"A"];
}];
NSLog(@"%@",[array objectsAtIndexes:indexset]);
// I want to indicate index of NSIndexSet object.
NSLog(@"%d",[indexset ?]);
everyone.
I want to indicate index of NSIndexSet
object.
Find various method but I can't find.
How to indicate index of NSIndexSet
object?
NSMutableArray *array = [[NSMutableArray alloc]initWithObjects:@"A",@"B",@"C",@"A", nil];
NSIndexSet *indexset = [array indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return [obj isEqual:@"A"];
}];
NSLog(@"%@",[array objectsAtIndexes:indexset]);
// I want to indicate index of NSIndexSet object.
NSLog(@"%d",[indexset ?]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想获取存储在 NSIndexSet 中的索引数量,请使用 count 属性:
If you want to get number of indices stored in NSIndexSet then use count property:
从 iOS 4.0 开始,>很少有方法可以枚举
NSIndexSet
,这是回答这个问题的,
- (void)enumerateIndexesUsingBlock:(void (^)(NSUInteger idx, BOOL *stop))block
From, iOS 4.0 and > there's few method which enumerates the
NSIndexSet
,here's the one which answering to this question,
- (void)enumerateIndexesUsingBlock:(void (^)(NSUInteger idx, BOOL *stop))block