Is it possible to use a delegate of superclass on subclass
Example: Class A is superclass of class B and superclass A uses the text view method example textviewDidChange. can I somehow call [super textViewDidChange] of superclass A on Subclass B even it isn't on header file of class A if i rediclare the method on subclass B
When you specify UITextViewDelegate
, you're telling the compiler that your class
meets the specifications for a UITextViewDelegate
. If class A
has all the requirements for a UITextViewDelegate
, and class B
is a subclass, then it too will have all the requirements. Nothing will stop you from assigning any instance
as a delegate
, so you still have to be careful with that.
Yes,you can. Since class A confirms <UITextViewDelegate> protocol there is no need to redeclare them in header file. Just make sure it implements needed methods.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.