tags:

views:

16

answers:

1

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
thx for response but i got a warning : Comparison of distinct objective-c struct NSNull and struct NSString lacks a cast
the1nz4ne
but it works...
the1nz4ne
you can avoid the warning by using the somewhat more verbose:if ([[NSNull null] isEqual:text] || title.length == 0)
ennuikiller
thx its working
the1nz4ne