开发者

How to avoid overriding of methods in subclass in objective c

Can anyone please guide me on how to avoid overriding of superc开发者_开发技巧lass methods in subclass in Objective-C, like the "final" concept in Java.


You can't. You can't even be sure that a leaf class's methods are the ones you supplied, because we can use the Objective-C runtime library to replace method implementations in a running application. That's a deliberate feature of the runtime library's design.


Well I'm not sure about a "final" equivalent in objective c but if there are methods in a super class that you don't want called just don't write that particular method in your sub class

Plus I think a method written with "+" prefix as opposed to "-" is a class method and not an instance method so that method should always be the same.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜