I have a short question is someone wants +15 rep. 😀
//This returns nothing, nil, or "" (no quotes)
NSLog(@"alert view text field : %@",[alertView textFieldAtIndex:0].text);
//In theory this if-condition should NOT pass
if([alertView textFieldAtIndex:0].text != nil || [alertView textFieldAtIndex:0].text != @"")
{
NSLog(@"IF!");
}
//in other words, "else" should run
else {
NSLog(@"ELSE");
}
Instead I get this as output:
[29929:fb03]alert view text field :
[29929:fb03]IF!
EIDT: ok, as answered by the questions, i put in
if(!([[alertView textFieldAtIndex:0].text isEqualToString:@""]) || !([[alertView textFieldAtIndex:0].text isEqualToString: nil]) || !([alertView textFieldAtIndex:0].text != nil))
but the if STILL passes and it shouldn’t. I dont get it. 🙁
Always use isEqualToString method to compare strings
!([alertView textFieldAtIndex:0].text isEqualToString:@””])