Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added insert section at index and after section #13

Merged
merged 1 commit into from
Apr 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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