I’m trying to debug my iPhone app (a basic counter) and I have a “goto” function to go to a specific number. When testing my app, I noticed that when set the goto without putting anything into the NSTextField, it doesn’t return anything. Not a NULL, nil, or anything. NSLogging the input string doesn’t even show up in console. No blank message, no NULL message, nothing. If you want to see my code, here it is:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
switch(buttonIndex) {
case 0:
break;
case 1:
NSLog(@"Method called");
NSLog(@"%@", [[alertView textField] text]);
if ([[alertView textField] text] != NULL) {
count = [[[alertView textField] text] intValue];
[label setText:[[alertView textField] text]];
} else {
break;
}
}
}
“Method called” always shows up, but the next line doesn’t come up at all on a case with no input.
Thanks in advance!
It doesn’t show up because I suspect that it has nothing to show!
If you really want to show it no matter what try:
This way it’ll show the first part of the string and then if its got any text to display it’ll append that as well
I’ve just done a very small test and using
and nothing is shown in the console
::edit::
If your trying to get the if statement to work you could try using something like
What it seems is happening is that the
[[alertView textField] text]is returning an NSString of@""and notNULLornil.