Skip to content

Instantly share code, notes, and snippets.

@christianroman
Created August 3, 2012 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save christianroman/3248993 to your computer and use it in GitHub Desktop.
Save christianroman/3248993 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( [self 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