Skip to content

Instantly share code, notes, and snippets.

@pablocarrillo
Created September 6, 2013 09:31
Show Gist options
  • Save pablocarrillo/6461590 to your computer and use it in GitHub Desktop.
Save pablocarrillo/6461590 to your computer and use it in GitHub Desktop.
Fast range of indexPath utility
/*!
*\brief Method to get an array of index path from a NSRange
* This method can be used to get an array of indexPath for table updates,
* just one range and section each time.
*\param range The range you need for the indexPath
*\param the section you want for the indexPath
*\return A Mutable array of NSIndexPath
*/
+ (NSMutableArray*)arrayOfIndexPathFromRange:(NSRange)range section:(NSUInteger)section{
NSMutableArray *returnArray=[NSMutableArray new];
NSInteger i=0;
while (i<range.length) {
i++;
[returnArray addObject:[NSIndexPath indexPathForRow:(range.location+i) inSection:section]];
}
return returnArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment