Chapter 4
I am really new to this but i have been searching for a day and can't figure out what i am doing wrong. I am using Xcode version 6.1. In chapter 4 when we put in the text field and add the code in the view controller.m file, when i add self.bandobject = [[BandObject alloc] init]; it give me and error. Use of undeclared identifier and asks me if i want to try to change the name to_bandObject. Can someone tell me what i need to fix and the reason this is happening so i know how to avoid it in the future. Thanks in advance.
Here is my code
// ViewController.m
// Bands
//
//
// Copyright (c) 2015 Idea Monkey Studios. All rights reserved.
//
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog(@"titleLabel.text = %@", self.titleLabel.text);
self.bandObject = [[BandObject alloc] init];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return YES;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
self.bandObject.name = self.nameTextField.text;
[self.nameTextField resignFirstResponder];
return YES;
}
-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
self.bandObject.name =self.nameTextField.text;
[self saveBandObject];
[self.nameTextField resignFirstResponder];
return YES;
}
@end
//
// ViewController.h
// Bands
//
//
// Copyright (c) 2015 Idea Monkey Studios. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "WBABand.h"
@interface ViewController : UIViewController <UITextFieldDelegate>
@property (nonatomic, strong) WBABand *bandObject;
@property (nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (nonatomic, weak) IBOutlet UITextField *nameTextField;
@end
|