Created
June 8, 2015 19:19
-
-
Save alexfaber2011/369daa6eadd79e2e9e7c to your computer and use it in GitHub Desktop.
Form Value Grabbing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Gather all of the form fields | |
NSMutableArray *smsValues = [[NSMutableArray alloc] initWithCapacity:3]; | |
NSMutableArray *phoneValues = [[NSMutableArray alloc] initWithCapacity:3]; | |
NSMutableArray *emailValues = [[NSMutableArray alloc] initWithCapacity:3]; | |
NSArray *smsCells = [self.smsTable visibleCells]; | |
NSArray *phoneCells = [self.phoneCallTable visibleCells]; | |
NSArray *emailCells = [self.emailTable visibleCells]; | |
for(NSUInteger i = 0; i < smsCells.count; i++){ | |
//Does the compiler optimize this? | |
NSString *tempSmsText = ((MainCell *)smsCells[i]).textField.text; | |
NSString *tempPhoneText = ((MainCell *)phoneCells[i]).textField.text; | |
NSString *tempEmailText = ((MainCell *)emailCells[i]).textField.text; | |
if(![tempSmsText isEqualToString:@""])[smsValues addObject:tempSmsText]; | |
if(![tempPhoneText isEqualToString:@""])[phoneValues addObject:tempPhoneText]; | |
if(![tempEmailText isEqualToString:@""])[emailValues addObject:tempEmailText]; | |
} | |
NSDictionary *newValues = @{ | |
@"dnd" : @{ | |
@"beginTime" : ((DNDCell *) [self.doNotDisturbTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]).fieldTextField.text, | |
@"endTime" : ((DNDCell *) [self.doNotDisturbTable cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]]).fieldTextField.text | |
}, | |
@"sms" : [[NSArray alloc] initWithArray:smsValues copyItems:YES], | |
@"phone" : [[NSArray alloc] initWithArray:phoneValues copyItems:YES], | |
@"email" : [[NSArray alloc] initWithArray:emailValues copyItems:YES] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment