Skip to content

Commit

Permalink
add ability to set header/footer for selected section
Browse files Browse the repository at this point in the history
  • Loading branch information
DenTelezhkin committed Oct 12, 2014
1 parent 1550645 commit 1d8eab5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ language: objective-c

before_install:
- sudo gem install cocoapods --no-document --quiet
- sudo gem install ios_ci --no-document --quiet
- brew install ios-sim
- export LANG=en_US.UTF-8
- cd DTModelStorageTests

script: ios_ci cedar --source-root $TRAVIS_BUILD_DIR/DTModelStorageTests --workspace DTModelStorageTests.xcworkspace --scheme Tests --build-path Build/Products
script: rake
20 changes: 19 additions & 1 deletion DTModelStorage/Memory/DTMemoryStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,30 @@
- (void)setSupplementaries:(NSArray *)supplementaryModels forKind:(NSString *)kind;

/**
Set header models for UITableView sections. `DTSectionModel` objects are created automatically, if they don't exist already. Pass nil or empty array to this method to clear all section header models.
Set header models for sections. `DTSectionModel` objects are created automatically, if they don't exist already. Pass nil or empty array to this method to clear all section header models.
@param headerModels Section header models to use.
*/
- (void)setSectionHeaderModels:(NSArray *)headerModels;

/**
Set header model for section. `DTSectionModel` object is created automatically, if it doesn't exist already.
@param headerModel Section header model to use.
@param sectionNumber Number of the section
*/
- (void)setSectionHeaderModel:(id)headerModel forSectionIndex:(NSUInteger)sectionNumber;

/**
Set footer model for section. `DTSectionModel` object is created automatically, if it doesn't exist already.
@param footerModel Section header model to use.
@param sectionNumber Number of the section
*/
- (void)setSectionFooterModel:(id)footerModel forSectionIndex:(NSUInteger)sectionNumber;

/**
Set footer models for sections. `headerKind` property is used to define kind of header supplementary. `DTSectionModel` objects are created automatically, if they don't exist already. Pass nil or empty array to this method to clear all section footer models.
Expand Down
18 changes: 18 additions & 0 deletions DTModelStorage/Memory/DTMemoryStorage.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ - (id)supplementaryModelOfKind:(NSString *)kind forSectionIndex:(NSUInteger)sect
return [sectionModel supplementaryModelOfKind:kind];
}

-(void)setSectionHeaderModel:(id)headerModel forSectionIndex:(NSUInteger)sectionNumber
{
NSAssert(self.supplementaryHeaderKind, @"supplementaryHeaderKind property was not set before calling setSectionHeaderModel: forSectionIndex: method");

DTSectionModel * section = [self sectionAtIndex:sectionNumber];

[section setSupplementaryModel:headerModel forKind:self.supplementaryHeaderKind];
}

-(void)setSectionFooterModel:(id)footerModel forSectionIndex:(NSUInteger)sectionNumber
{
NSAssert(self.supplementaryHeaderKind, @"supplementaryFooterKind property was not set before calling setSectionFooterModel: forSectionIndex: method");

DTSectionModel * section = [self sectionAtIndex:sectionNumber];

[section setSupplementaryModel:footerModel forKind:self.supplementaryFooterKind];
}

-(id)headerModelForSectionIndex:(NSInteger)index
{
NSAssert(self.supplementaryHeaderKind, @"supplementaryHeaderKind property was not set before calling headerModelForSectionIndex: method");
Expand Down

0 comments on commit 1d8eab5

Please sign in to comment.