开发者

What exactly is an "extension" in objective-c?

开发者 https://www.devze.com 2023-01-03 17:32 出处:网络
It\'s something开发者_运维知识库 different than a category, right?From The Objective-C Programming Language: Categories and Extensions:

It's something开发者_运维知识库 different than a category, right?


From The Objective-C Programming Language: Categories and Extensions:

A category allows you to add methods to an existing class—even to one to which you do not have the source. This is a powerful feature that allows you to extend the functionality of existing classes without subclassing. Using categories, you can also split the implementation of your own classes between several files. Class extensions are similar, but allow additional required API to be declared for a class in locations other than within the primary class @interface block.
[...]
Class extensions are like “anonymous” categories, except that the methods they declare must be implemented in the main @implementation block for the corresponding class.

0

精彩评论

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

关注公众号