Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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