Reputation: 3616
I want to override my MYViewController : UIViewController
's setView:
method, such that, I do not allow some one to set view
's property to nil
.
-(void)setView:(UIView*)view {
if (view == nil)
//ignore - make no change
else
//default performance
}
How can I do this?
Upvotes: 0
Views: 235
Reputation: 7410
Calling the super class only when you want the default behavior should do the work:
-(void)setView:(UIView*)view {
if (view == nil) {
//ignore - make no change
}
else {
//default performance
[super setView:view];
}
}
Upvotes: 2
Reputation: 1305
@synthesize view = _view;
-(void)setView:(UIView*)view {
if (view)
_view = view;
}
It could be done as simple as this. If view
is not nil, set the variable.
Upvotes: 0