Skip to content

Commit

Permalink
Merge pull request #13 from shams-ahmed/master
Browse files Browse the repository at this point in the history
added insert section at index and after section
  • Loading branch information
Martin Barreto committed Apr 25, 2014
2 parents d54a42c + 99bc2ad commit f4eafff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions XLForm/XL/Descriptors/XLFormDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ typedef NS_ENUM(NSInteger, XLFormErrorCode)
+(XLFormDescriptor *)formDescriptorWithTitle:(NSString *)title;

-(void)addFormSection:(XLFormSectionDescriptor *)formSection;
-(void)addFormSection:(XLFormSectionDescriptor *)formSection atIndex:(NSUInteger)index;
-(void)addFormSection:(XLFormSectionDescriptor *)formSection afterSection:(XLFormSectionDescriptor *)afterSection;
-(void)addFormRow:(XLFormRowDescriptor *)formRow afterRow:(XLFormRowDescriptor *)afterRow;
-(void)addFormRow:(XLFormRowDescriptor *)formRow afterRowTag:(NSString *)afterRowTag;
-(void)removeFormSectionAtIndex:(NSUInteger)index;
Expand Down
15 changes: 15 additions & 0 deletions XLForm/XL/Descriptors/XLFormDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ -(void)addFormSection:(XLFormSectionDescriptor *)formSection
[self insertObject:formSection inFormSectionsAtIndex:[self.formSections count]];
}

-(void)addFormSection:(XLFormSectionDescriptor *)formSection atIndex:(NSUInteger)index
{
if (self.formSections.count >= index) {
[self insertObject:formSection inFormSectionsAtIndex:index];
}
}

-(void)addFormSection:(XLFormSectionDescriptor *)formSection afterSection:(XLFormSectionDescriptor *)afterSection
{
NSUInteger index = [self.formSections indexOfObject:afterSection];
if (index != NSNotFound) {
[self insertObject:formSection inFormSectionsAtIndex:[self.formSections indexOfObject:afterSection]+1];
}
}

-(void)addFormRow:(XLFormRowDescriptor *)formRow afterRow:(XLFormRowDescriptor *)afterRow
{
NSIndexPath * afterIndexPath = [self indexPathOfFormRow:afterRow];
Expand Down

0 comments on commit f4eafff

Please sign in to comment.