Assume the code for the iphone project:
IBOutlet UITextField* numberDisplay; @property (strong,nonatomic) IBOutlet UITextField *numberDisplay;
in the implementation file and
@synthesize numberDisplay;
in the implementation file. Also in implementation
-(IBAction)numberClicked:(id)sender { UIButton *buttonPressed = (UIButton *)sender; int val = buttonPressed.tag; if ( [numberDisplay.text compare:@"0"] == 0 ) { numberDisplay.text =[NSString stringWithFormat:@"%d", val ]; } else { numberDisplay.text = [NSString stringWithFormat:@"%@%d", numberDisplay.text, val ]; } }
When I launch the application, the display is not displayed in the UIText field, although the connections were made with IB, and it was proved that they were made by looking at the inspector. Even as a test, if I add lines
numberDisplay.text = @"a"; NSLog(@"the value is %@",numberDisplay.text); NSLog(@"the value is %@",numberDisplay);
I get a "null" value in both cases. Any ideas.
Can someone please tell me what is wrong with these two lines ?. Thanks.
Thanks to everyone. I started from scratch and now everything works. It looks like I had a file with the wrong label.
source share