是否可以将对象或数据成员添加到目标C中的类别? [英] Is it possible to add objects or data members to category in objective C?

查看:45
本文介绍了是否可以将对象或数据成员添加到目标C中的类别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道,使用类别我们可以向现有的类中添加函数.但是我怀疑,是否可以在目标C中将对象或数据成员添加到类别中?

we know that using category we can add functions to existing class. But i have a doubt that, Is it possible to add objects or data members to category in objective C ??

推荐答案

是的,您不能通过类别添加实例变量/成员/属性.您只能使用正在扩展的类已经提供的功能,但是当然您的新方法在被调用时可能会收到参数.

You're right, you cannot add instance variables / members / properties via a category. You can only work with what the class you're expanding already offers, but of course your new methods may receive arguments upon being called.

这篇关于是否可以将对象或数据成员添加到目标C中的类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆