Objective-C中的“类别”是什么? [英] What is “category” in Objective-C?
本文介绍了Objective-C中的“类别”是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何在Objective-C中使用类别?
我刚刚开始使用Objective-C,并且想知道我应该在目标C中何时何地使用类别。它是类还是协议?一个解释性的例子将会有很大的帮助。
谢谢
I am just getting started with Objective-C and was wondering when and where am i supposed to use category in objective C. is it a class or a protocol? An explanatory example would be of great help. Thanks
推荐答案
类别允许您将方法添加到现有类 - 甚至是您不使用的类拥有源。
A category allows you to add methods to an existing class—even to one for which you do not have the source.
类别是一个强大的功能,允许您扩展现有类的功能而无需子类化
Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing
检查苹果文档中的 Objective-C中的类别
这篇关于Objective-C中的“类别”是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文