I have a view controller which extends UIViewController.
@interface MyViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *phoneTxt;
@property (nonatomic, strong) NSDictionary *data;
@end
However when I try to set the property of the view controller by:
MyViewController *vvc = (MyViewController *)[sb instantiateViewControllerWithIdentifier:@"MyVC"];
vvc.data = data;
I get following error:
'NSInvalidArgumentException', reason: '-[UIViewController setData:]: unrecognized selector sent to instance
I have checked, the view controller is not nil and I have synthesized the property data in MyViewController.m
@synthesize data = _data;
Why am I getting this error?
I think you probably forgot to set the proper class for your view controller (File's Owner) in your storyboard/xib, so it probably gets instantiated as a raw
UIWievController
.