Recently I\'ve discovered webrtc-ios example from Github. While I was browsing though the project I noticed that VideoView class uses static method and I\'m not sure is that nec
One difference between using a static function and an Objective-C method is that the static function cannot be overriden in a subclass. If the common init code is done in a
- (void)setup;
method, and a subclass MyVideoView
of VideoView
happens to implement a method with the same name, then
[[MyVideoView alloc] initWithFrame:..]
will call the subclass implementation, which might not be wanted.
In your code,
initWithFrame
/initWithCoder
will always call the local init()
function, even if
an instance of a subclass is initialized.
If the common initialization is done in a method, then the method name should be more specific, to avoid that it is overriden "accidentally", for example
-(void)commonVideoViewSetup;