I’m unable to call a method or create a variable on my view controller. I’m using the following code but it doesn’t work.
// MODEL
@interface MyModel : NSObject
-(void)awesome;
@end
@implementation MyModel
-(void)awesome {
NSLog(@"awesome");
}
@end
// VIEW CONTROLLER
@interface MyViewController: UIViewController
@property (nonatomic, strong) MyModel *modelObject;
@end
@implementation MyViewController
@synthesize modelObject;
-(void)viewDidLoad
{
[self.modelObject awesome];
[super viewDidLoad];
}
@end
viewDidLoad lacks a
self.modelObject = [MyModel new];. Without it, modelObject is nil, and ignores the call to awesome. That’s also why creating a variable and assigning a value didn’t work.