发现一个api 发表于 2016-10-17 分类于 iOS 阅读次数: 发现一个好用的api,用于找出selectedItem 在 dataSource 里面的位置,适用于tableView和collectionView 123456NSIndexSet *indexSet = [self.photos indexesOfObjectsPassingTest:^BOOL(DKPhoto * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([self.selectedPhotoArray containsObject:obj]) { return YES; } return NO;}];