1
votes

I created a new custom view class (subclass of UIView) and changed the view's class in interface builder. However, it seems neither Xcode nor the compiler knows my view controller's view has changed class.

For instance, I have a selector in my custom view: -(void) changeShape I try to call in my view controller [self.view changeShape], there is no auto-completion and the compiler produces a warning that "view may not respond to changeShape".

The app runs in the simulator without issue though.

I wonder how to properly let the compiler know the view's class has been changed?

Thanks

Leo

1
can you please post your method declaration and definition?Waqas Raja
Maybe try cleaning the target because sounds a bit weird, I've done that without problems.Herz Rod
To know view class use this code NSString *className = NSStringFromClass([self.view class]); But I guess it's useless for your aim, just cast type [(MyView*)self.view changeShape];beryllium

1 Answers

1
votes

A simple solution would be to typecast self.view: [(YourViewClass *)self.view changeShape] Make sure you import the header file for YourViewClass as well and the compiler should not give you a warning.