Add section index

This commit is contained in:
Roman Efimov
2013-03-13 15:53:17 -05:00
parent b21f577793
commit c6fb707b2d
4 changed files with 43 additions and 12 deletions

View File

@@ -105,20 +105,20 @@
- (RETableViewSection *)addSection:(RETableViewSection *)section;
- (void)addSectionsFromArray:(NSArray *)array;
- (RETableViewSection *)insertSection:(id)section atIndex:(NSUInteger)index;
- (RETableViewSection *)insertSection:(RETableViewSection *)section atIndex:(NSUInteger)index;
- (void)insertSections:(NSArray *)sections atIndexes:(NSIndexSet *)indexes;
///-----------------------------
/// @name Removing Sections
///-----------------------------
- (void)removeSection:(id)section;
- (void)removeSection:(RETableViewSection *)section;
- (void)removeAllSections;
- (void)removeSectionIdenticalTo:(id)section inRange:(NSRange)range;
- (void)removeSectionIdenticalTo:(id)section;
- (void)removeSectionIdenticalTo:(RETableViewSection *)section inRange:(NSRange)range;
- (void)removeSectionIdenticalTo:(RETableViewSection *)section;
- (void)removeSectionsInArray:(NSArray *)otherArray;
- (void)removeSectionsInRange:(NSRange)range;
- (void)removeSection:(id)section inRange:(NSRange)range;
- (void)removeSection:(RETableViewSection *)section inRange:(NSRange)range;
- (void)removeLastSection;
- (void)removeSectionAtIndex:(NSUInteger)index;
- (void)removeSectionsAtIndexes:(NSIndexSet *)indexes;
@@ -127,7 +127,7 @@
/// @name Replacing Sections
///-----------------------------
- (void)replaceSectionAtIndex:(NSUInteger)index withSection:(id)section;
- (void)replaceSectionAtIndex:(NSUInteger)index withSection:(RETableViewSection *)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;

View File

@@ -201,27 +201,33 @@
- (RETableViewSection *)addSection:(RETableViewSection *)section
{
section.tableViewManager = self;
[_sections addObject:section];
return section;
}
- (void)addSectionsFromArray:(NSArray *)array
{
for (RETableViewSection *section in array)
section.tableViewManager = self;
[_sections addObjectsFromArray:array];
}
- (RETableViewSection *)insertSection:(id)section atIndex:(NSUInteger)index
- (RETableViewSection *)insertSection:(RETableViewSection *)section atIndex:(NSUInteger)index
{
section.tableViewManager = self;
[_sections insertObject:section atIndex:index];
return section;
}
- (void)insertSections:(NSArray *)sections atIndexes:(NSIndexSet *)indexes
{
for (RETableViewSection *section in sections)
section.tableViewManager = self;
[_sections insertObjects:sections atIndexes:indexes];
}
- (void)removeSection:(id)section
- (void)removeSection:(RETableViewSection *)section
{
[_sections removeObject:section];
}
@@ -231,12 +237,12 @@
[_sections removeAllObjects];
}
- (void)removeSectionIdenticalTo:(id)section inRange:(NSRange)range
- (void)removeSectionIdenticalTo:(RETableViewSection *)section inRange:(NSRange)range
{
[_sections removeObjectIdenticalTo:section inRange:range];
}
- (void)removeSectionIdenticalTo:(id)section
- (void)removeSectionIdenticalTo:(RETableViewSection *)section
{
[_sections removeObjectIdenticalTo:section];
}
@@ -251,7 +257,7 @@
[_sections removeObjectsInRange:range];
}
- (void)removeSection:(id)section inRange:(NSRange)range
- (void)removeSection:(RETableViewSection *)section inRange:(NSRange)range
{
[_sections removeObject:section inRange:range];
}
@@ -271,18 +277,23 @@
[_sections removeObjectsAtIndexes:indexes];
}
- (void)replaceSectionAtIndex:(NSUInteger)index withSection:(id)section
- (void)replaceSectionAtIndex:(NSUInteger)index withSection:(RETableViewSection *)section
{
section.tableViewManager = self;
[_sections replaceObjectAtIndex:index withObject:section];
}
- (void)replaceSectionsAtIndexes:(NSIndexSet *)indexes withSections:(NSArray *)sections
{
for (RETableViewSection *section in sections)
section.tableViewManager = self;
[_sections replaceObjectsAtIndexes:indexes withObjects:sections];
}
- (void)replaceSectionsInRange:(NSRange)range withSectionsFromArray:(NSArray *)otherArray range:(NSRange)otherRange
{
for (RETableViewSection *section in otherArray)
section.tableViewManager = self;
[_sections replaceObjectsInRange:range withObjectsFromArray:otherArray range:otherRange];
}

View File

@@ -25,6 +25,8 @@
#import <Foundation/Foundation.h>
@class RETableViewManager;
/**
Table view section.
*/
@@ -55,6 +57,13 @@
*/
@property (strong, readwrite, nonatomic) UIView *footerView;
@property (weak, readwrite, nonatomic) RETableViewManager *tableViewManager;
/**
Section index in UITableView.
*/
@property (assign, readonly, nonatomic) NSUInteger index;
///-----------------------------
/// @name Creating and Initializing a RETableViewSection
///-----------------------------

View File

@@ -24,6 +24,7 @@
//
#import "RETableViewSection.h"
#import "RETableViewManager.h"
@implementation RETableViewSection
@@ -105,6 +106,16 @@
return self;
}
#pragma mark -
#pragma mark Reading information
- (NSUInteger)index
{
RETableViewManager *tableViewManager = self.tableViewManager;
return [tableViewManager.sections indexOfObject:self];
}
#pragma mark -
#pragma mark Managing items