Index: ios/chrome/browser/ui/collection_view/collection_view_model.mm |
diff --git a/ios/chrome/browser/ui/collection_view/collection_view_model.mm b/ios/chrome/browser/ui/collection_view/collection_view_model.mm |
index 0866b37bdafde7636ef71ab9c88f608417224f14..460091ffc9a7435bbbc74e89834abac1689c72fa 100644 |
--- a/ios/chrome/browser/ui/collection_view/collection_view_model.mm |
+++ b/ios/chrome/browser/ui/collection_view/collection_view_model.mm |
@@ -267,6 +267,25 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems; |
return [NSIndexPath indexPathForItem:itemIndex inSection:section]; |
} |
+- (BOOL)hasItem:(CollectionViewItem*)item { |
+ for (SectionItems* sectionItems in _sections) { |
lpromero
2017/03/28 09:09:08
Iterate on _sectionIdentifiers and use haseItem:in
gambard
2017/03/28 13:35:22
I wanted to offer a solution without the current i
|
+ if ([sectionItems indexOfObject:item] != NSNotFound) |
+ return YES; |
+ } |
+ return NO; |
+} |
+ |
+- (NSIndexPath*)indexPathForItem:(CollectionViewItem*)item { |
+ for (NSUInteger section = 0; section < [_sections count]; section++) { |
lpromero
2017/03/28 09:09:08
Idem, use the same methods that use the sectionIde
gambard
2017/03/28 13:35:22
This method was slightly more efficient (lookup on
|
+ NSInteger itemIndex = [_sections[section] indexOfObject:item]; |
+ if (itemIndex != NSNotFound) { |
+ return [NSIndexPath indexPathForItem:itemIndex inSection:section]; |
+ } |
+ } |
+ DCHECK(NO); |
lpromero
2017/03/28 09:09:08
Use NOTREACHED().
gambard
2017/03/28 13:35:22
Done.
|
+ return nil; |
+} |
+ |
#pragma mark UICollectionView data sourcing |
- (NSInteger)numberOfSections { |