Skip to content

Instantly share code, notes, and snippets.

@daniel-rueda
Forked from christianroman/gist:3248993
Created August 8, 2012 02:04
Show Gist options
  • Save daniel-rueda/3291397 to your computer and use it in GitHub Desktop.
Save daniel-rueda/3291397 to your computer and use it in GitHub Desktop.
Check if UITextFields are empty using Objective-C
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