|
|
#1 |
|
Stupid Question. String values
I'm new to C/ObjC and am wondering why this statement is always true when I known darn well there's no text in the UITextFields referenced...
Code:
if(txtEmail.text != @"" && txtPassword.text != @""){
...
}
|
|
|
|
0
|
|
|
#2 |
|
Objective-C strings are actually an instance of the NSString class - even the @"xxx" literals. Therefore what you are comparing is the addresses of the class instances and so both sides of each '!=' will always be different and so the '!=' will always 'true'.
What you want is something like (of the top of my head): if( NO == [txtEmail.text isEqualTo:@""] && NO == [txtPassword.text isEqualTo:@""]) An alternative is: if(* NSOrderedSame != [txtEmail.text compare:@""]......... (I suggest you look up the isEqualTo: and compare: functions to get the syntax right - I'm just going form memory). Susan |
|
|
|
0
|
|
|
#3 | |
|
Many thanks, Susan! *removes dunce cap and returns to desk*
Code:
if(![txtEmail.text isEqualToString:@""] && ![txtPassword.text isEqualToString:@""]){
[btnLogin setEnabled:YES];
}
Quote:
|
||
|
|
0
|
|
|
#4 |
|
isEqualTo: doesn't exist on the phone. Use isEqualToString: Even down unda.
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| NSMutable Array, custom object losing string values | AZWolf7 | iPhone/iPad Programming | 2 | Oct 24, 2010 10:46 AM |
| iWork Numbers: Finding a string value based on a string | ert3 | Mac Applications and Mac App Store | 6 | Jul 19, 2010 09:43 AM |
| adding a string value to an NSTableView | Chirone | Mac Programming | 4 | Jun 19, 2009 09:34 AM |
| function takes string parameter and returns string value | vidyareef | iPhone/iPad Programming | 3 | Jan 21, 2009 04:50 PM |
| Ask a Stupid Question, Get a Stupid Answer | Perceptes | Community | 12 | May 7, 2003 08:29 AM |
All times are GMT -5. The time now is 10:06 PM.







Linear Mode

