hi, i got a textfield and i want to send a UIAlertView if the user enter nothing in the textfield.
+1
A:
First capture the input:
NSString *text = myTextField.text;
Then test for null string and present alertview:
if (title == [NSNull null] || title.length == 0 ) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:button1 otherButtonTitles:button2, nil];
[alertView show];
}
ennuikiller
2010-06-20 15:08:53
thx for response but i got a warning : Comparison of distinct objective-c struct NSNull and struct NSString lacks a cast
the1nz4ne
2010-06-20 15:12:44
but it works...
the1nz4ne
2010-06-20 15:13:49
you can avoid the warning by using the somewhat more verbose:if ([[NSNull null] isEqual:text] || title.length == 0)
ennuikiller
2010-06-20 15:16:16
thx its working
the1nz4ne
2010-06-20 15:22:34