I want to use insertRowsAtIndexPaths method to insert a row to a UITableView, but I don't know how to make "indexPaths" property for this method.
Please help me!
I want to use insertRowsAtIndexPaths method to insert a row to a UITableView, but I don't know how to make "indexPaths" property for this method.
Please help me!
You can create single NSIndexPath using
+ (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section; // defined in UITableView.h
Your code to create and fill indexPaths paramater may look like:
NSMutableArray* indexPaths = [NSMutableArray arrayWithCapacity:10];
for (...) // iterate to get all indexes and section you need
{
[indexPaths addObject:[NSIndexPath indexPathForRow:someRow inSection:someSection]];
}
//indexPaths is ready to use
- (NSIndexPath *) indexPathForRow:(NSUInteger)row andSection:(NSUInteger)section {
NSUInteger _path[2] = {section, row};
NSIndexPath *_indexPath = [[NSIndexPath alloc] initWithIndexes:_path length:2];
return [_indexPath autorelease];
}