Ans : Subclassing is way of inheriting
property of one class to another class. Child class inherit all behaviour of
parent class. Let's talk about UIImageView.
I have made one class as SpecialImageView which
inherit UIImageView. So SpecialImageView is subclass and UIImageView is parent class.
NSObject > UIResponder > UIView
> UIImageView
Suppose I want 5 imageview in my viewcontroller, which has default behaviour like
borderWidth =2, broderColor = blue.
So I have written this behaviour in
SpecialImageView class once. All those 5 images are as SpecialImageView instead of UIImageView.
So I do not need to write to all this behaviour for every
5 imageviews. So subclassing gives benefit of customisation of any class.
When we want custom UITableViewCell then we need to
make subclass of UITableViewCell.
No comments:
Post a Comment
Thanks