leo
leo

Reputation: 1011

how to let view controller know its view's class?

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

Upvotes: 1

Views: 100

Answers (1)

Jakob W
Jakob W

Reputation: 3377

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.

Upvotes: 1

Related Questions