-2
@implementation ViewController
-(IBAction)changelabel {
NSString *string1 =entername.text;
NSString *string2 =@"Alan Shearer";
NSString *string3 =@"Alan Shearer 260 Goals";

if([string1 isEqualToString:string2])

{label.text=string3;}
}

I want it so, when the user enters "Alan Shearer" into a text field it changes the label to Alan Shearer

Jeevan Thandi
  • 158
  • 2
  • 11

2 Answers2

1

Add a sender to your method

-(IBAction)changeLabel:(id)sender 
TheAmateurProgrammer
  • 9,252
  • 8
  • 52
  • 71
0

What does NSLog(@"%@", string1) write? Your NSString comparison method is right.

dreamzor
  • 5,795
  • 4
  • 41
  • 61
  • How do I view NSLog? There are no errors and it still does not work and it shows no errors. When I run the app, and press check, it closes the app. – Jeevan Thandi Sep 23 '12 at 14:50
  • Just add this piece of code before your `if` statement and look in console output. – dreamzor Sep 23 '12 at 14:51
  • that obviously means the method is not called, which indicates you didn't make up a connection with the `IBAction`. – dreamzor Sep 23 '12 at 21:16