Extract a range from NSArray Extract a range from NSArray objective-c objective-c

Extract a range from NSArray


 static const NSUInteger ItemsPerView = 20; NSUInteger startIndex = viewIndex * ItemsPerView; NSUInteger count = MIN( completeArray.count - startIndex, ItemsPerView ); NSArray *itemsForView = [completeArray subarrayWithRange: NSMakeRange( startIndex, count )];


Your answer is in your question. Just keep track of which NSRange belongs to which view and use it to look up the necessary objects in your container using NSArray's -subarrayWithRange: method.