mirror of
https://github.com/zhigang1992/RETableViewManager.git
synced 2026-05-23 11:46:35 +08:00
Add array shortcuts
This commit is contained in:
@@ -45,8 +45,16 @@
|
||||
@property (strong, nonatomic) RETableViewCellStyle *style;
|
||||
@property (assign, nonatomic) id<RETableViewManagerDelegate>delegate;
|
||||
|
||||
///-----------------------------
|
||||
/// @name Creating and Initializing a RETableViewManager
|
||||
///-----------------------------
|
||||
|
||||
- (id)initWithDelegate:(id<RETableViewManagerDelegate>)delegate;
|
||||
- (RETableViewSection *)addSection:(RETableViewSection *)section;
|
||||
|
||||
///-----------------------------
|
||||
/// @name Mapping
|
||||
///-----------------------------
|
||||
|
||||
- (void)mapObjectClass:(NSString *)objectClass toTableViewCellClass:(NSString *)cellViewClass;
|
||||
|
||||
@end
|
||||
@@ -57,6 +65,51 @@
|
||||
|
||||
- (void)tableView:(UITableView *)tableView styleCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath;
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath item:(id)item;
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath item:(id)items;
|
||||
|
||||
@end
|
||||
|
||||
@interface RETableViewManager (REExtendedTableViewManager)
|
||||
|
||||
///-----------------------------
|
||||
/// @name Adding sections
|
||||
///-----------------------------
|
||||
|
||||
- (RETableViewSection *)addSection:(RETableViewSection *)section;
|
||||
- (void)addSectionsFromArray:(NSArray *)array;
|
||||
- (RETableViewSection *)insertSection:(id)section atIndex:(NSUInteger)index;
|
||||
- (void)insertSections:(NSArray *)sections atIndexes:(NSIndexSet *)indexes;
|
||||
|
||||
///-----------------------------
|
||||
/// @name Removing Sections
|
||||
///-----------------------------
|
||||
|
||||
- (void)removeSection:(id)section;
|
||||
- (void)removeAllSections;
|
||||
- (void)removeSectionIdenticalTo:(id)section inRange:(NSRange)range;
|
||||
- (void)removeSectionIdenticalTo:(id)section;
|
||||
- (void)removeSectionsInArray:(NSArray *)otherArray;
|
||||
- (void)removeSectionsInRange:(NSRange)range;
|
||||
- (void)removeSection:(id)section inRange:(NSRange)range;
|
||||
- (void)removeLastSection;
|
||||
- (void)removeSectionAtIndex:(NSUInteger)index;
|
||||
- (void)removeSectionsAtIndexes:(NSIndexSet *)indexes;
|
||||
|
||||
///-----------------------------
|
||||
/// @name Replacing Sections
|
||||
///-----------------------------
|
||||
|
||||
- (void)replaceSectionAtIndex:(NSUInteger)index withSection:(id)section;
|
||||
- (void)replaceSectionsAtIndexes:(NSIndexSet *)indexes withSections:(NSArray *)sections;
|
||||
- (void)replaceSectionsInRange:(NSRange)range withSectionsFromArray:(NSArray *)otherArray range:(NSRange)otherRange;
|
||||
- (void)replaceSectionsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray;
|
||||
|
||||
///-----------------------------
|
||||
/// @name Rearranging Content
|
||||
///-----------------------------
|
||||
|
||||
- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2;
|
||||
- (void)sortSectionsUsingFunction:(NSInteger (*)(id, id, void *))compare context:(void *)context;
|
||||
- (void)sortSectionsUsingSelector:(SEL)comparator;
|
||||
|
||||
@end
|
||||
@@ -63,12 +63,6 @@
|
||||
[self mapObjectClass:@"RECreditCardItem" toTableViewCellClass:@"RETableViewCreditCardCell"];
|
||||
}
|
||||
|
||||
- (RETableViewSection *)addSection:(RETableViewSection *)section
|
||||
{
|
||||
[_sections addObject:section];
|
||||
return section;
|
||||
}
|
||||
|
||||
- (void)mapObjectClass:(NSString *)objectClass toTableViewCellClass:(NSString *)cellViewClass
|
||||
{
|
||||
[_mapping setObject:cellViewClass forKey:objectClass];
|
||||
@@ -194,4 +188,119 @@
|
||||
[_delegate tableView:tableView didSelectRowAtIndexPath:indexPath item:item];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Managing sections
|
||||
|
||||
@implementation RETableViewManager (REExtendedTableViewManager)
|
||||
|
||||
- (RETableViewSection *)addSection:(RETableViewSection *)section
|
||||
{
|
||||
[_sections addObject:section];
|
||||
return section;
|
||||
}
|
||||
|
||||
- (void)addSectionsFromArray:(NSArray *)array
|
||||
{
|
||||
[_sections addObjectsFromArray:array];
|
||||
}
|
||||
|
||||
- (RETableViewSection *)insertSection:(id)section atIndex:(NSUInteger)index
|
||||
{
|
||||
[_sections insertObject:section atIndex:index];
|
||||
return section;
|
||||
}
|
||||
|
||||
- (void)insertSections:(NSArray *)sections atIndexes:(NSIndexSet *)indexes
|
||||
{
|
||||
[_sections insertObjects:sections atIndexes:indexes];
|
||||
}
|
||||
|
||||
- (void)removeSection:(id)section
|
||||
{
|
||||
[_sections removeObject:section];
|
||||
}
|
||||
|
||||
- (void)removeAllSections
|
||||
{
|
||||
[_sections removeAllObjects];
|
||||
}
|
||||
|
||||
- (void)removeSectionIdenticalTo:(id)section inRange:(NSRange)range
|
||||
{
|
||||
[_sections removeObjectIdenticalTo:section inRange:range];
|
||||
}
|
||||
|
||||
- (void)removeSectionIdenticalTo:(id)section
|
||||
{
|
||||
[_sections removeObjectIdenticalTo:section];
|
||||
}
|
||||
|
||||
- (void)removeSectionsInArray:(NSArray *)otherArray
|
||||
{
|
||||
[_sections removeObjectsInArray:otherArray];
|
||||
}
|
||||
|
||||
- (void)removeSectionsInRange:(NSRange)range
|
||||
{
|
||||
[_sections removeObjectsInRange:range];
|
||||
}
|
||||
|
||||
- (void)removeSection:(id)section inRange:(NSRange)range
|
||||
{
|
||||
[_sections removeObject:section inRange:range];
|
||||
}
|
||||
|
||||
- (void)removeLastSection
|
||||
{
|
||||
[_sections removeLastObject];
|
||||
}
|
||||
|
||||
- (void)removeSectionAtIndex:(NSUInteger)index
|
||||
{
|
||||
[_sections removeObjectAtIndex:index];
|
||||
}
|
||||
|
||||
- (void)removeSectionsAtIndexes:(NSIndexSet *)indexes
|
||||
{
|
||||
[_sections removeObjectsAtIndexes:indexes];
|
||||
}
|
||||
|
||||
- (void)replaceSectionAtIndex:(NSUInteger)index withSection:(id)section
|
||||
{
|
||||
[_sections replaceObjectAtIndex:index withObject:section];
|
||||
}
|
||||
|
||||
- (void)replaceSectionsAtIndexes:(NSIndexSet *)indexes withSections:(NSArray *)sections
|
||||
{
|
||||
[_sections replaceObjectsAtIndexes:indexes withObjects:sections];
|
||||
}
|
||||
|
||||
- (void)replaceSectionsInRange:(NSRange)range withSectionsFromArray:(NSArray *)otherArray range:(NSRange)otherRange
|
||||
{
|
||||
[_sections replaceObjectsInRange:range withObjectsFromArray:otherArray range:otherRange];
|
||||
}
|
||||
|
||||
- (void)replaceSectionsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray
|
||||
{
|
||||
[_sections replaceObjectsInRange:range withObjectsFromArray:otherArray];
|
||||
}
|
||||
|
||||
- (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2
|
||||
{
|
||||
[_sections exchangeObjectAtIndex:idx1 withObjectAtIndex:idx2];
|
||||
}
|
||||
|
||||
- (void)sortSectionsUsingFunction:(NSInteger (*)(id, id, void *))compare context:(void *)context
|
||||
{
|
||||
[_sections sortUsingFunction:compare context:context];
|
||||
}
|
||||
|
||||
- (void)sortSectionsUsingSelector:(SEL)comparator
|
||||
{
|
||||
[_sections sortUsingSelector:comparator];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user