View Single Post
  #9 (permalink)  
Old June 25th, 2011, 08:15 AM
thepianoguy thepianoguy is offline
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

There is nothing wrong with the code you provided. You mentioned using Simulator 3.1.1, which version of Xcode are you using? One of the common user errors in the 3.x.x versions of Xcode is failure to save changes made in Interface Builder, particularly after connecting Outlets or Actions. This is also a common omission in the book, as it is sometimes included as a step, and sometimes not, so verify your connections. The alertView will only show up if the correct PIN number is entered, the nameTextField can be blank. To check secretPin value and to check the connection in the btnClicked:(id)sender method insert the following
Code:
- (IBAction)btnClicked:(id)sender {
	NSLog(@"In buttonClicked. The secretPin is %@", secretPin);
	if ([secretPin isEqualToString: @"2345"]) {
	    NSString *str = [[NSString alloc] initWithFormat:@"Hello, %@", nameTextField.text ];
    	UIAlertView *alert = [[UIAlertView alloc]
				 	        initWithTitle:@"Hello"  
					        message: str   
					        delegate:self  
					        cancelButtonTitle:@"OK" 
					        otherButtonTitles:nil, nil]; 
        [alert show]; 
        [alert release]; 
	    [str release];
	}
}
Run the project and see what the console log displays.

If you still have problems, send the project to the email in my last post, and I will track down the issue and set you on the right path.

Bob