ok I have a press basic application with the following code in newAppViewController.m
When I run my app, the label i have called myLabel changes the text but the color of the view ALWAYS becomes blue not red. For some reason its always the else case!
Any Ideas?
-(IBAction)click:(id)sender{
NSString *mystr = [[NSString alloc]initWithFormat:@"%@",[[sender titleLabel] text] ];
myLabel.text = mystr;
if(myLabel.text == @"RED")
self.view.backgroundColor = [UIColor redColor];
else self.view.backgroundColor = [UIColor blueColor];
}
You can’t compare two string with “==” operator. Use the -isEqualToString: method for this.