-
-
Save daniel-rueda/3291397 to your computer and use it in GitHub Desktop.
Check if UITextFields are empty using Objective-C
This file contains 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
BOOL emptyTextFields(id toCompare,...) | |
{ | |
va_list args; | |
va_start(args, toCompare); | |
id value = nil; | |
BOOL match = NO; | |
while ( (value = va_arg(args,id)) ){ | |
if( [toCompare isKindOfClass:[NSString class]] && [value isKindOfClass:[UITextField class]] ){ | |
if( [[(UITextField *)value text] isEqualToString:toCompare] ) | |
match = YES; | |
} | |
} | |
va_end(args); | |
return match; | |
} | |
/* Usage */ | |
if( emptyTextFields(@"", // <-- compare to | |
sexo, | |
estadoFamiliar, | |
procedenciaFondos, | |
usoFondos, | |
profesion, | |
telefono, | |
nil) ) // <-- nil to finish | |
return; | |
else | |
NSLog ( @"valid UITextFields" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment