Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "ViewController.h"
- @interface ViewController ()
- - (IBAction)changeGreeting:(id)sender;
- @property (weak, nonatomic) IBOutlet UITextField *textFiled;
- @property (weak, nonatomic) IBOutlet UILabel *label;
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (IBAction)changeGreeting:(id)sender {
- self.userName = self.textFiled.text;
- NSString *nameString = self.userName;
- if ([nameString length] == 0)
- {
- nameString = @"World";
- }
- NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!", nameString];
- self.label.text = greeting;
- }
- - (BOOL) textFieldShouldReturn:(UITextField *)theTextField
- {
- if (theTextField == self.textFiled)
- {
- [theTextField resignFirstResponder];
- }
- return YES;
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement