How to add properties to NSMutableArray via category extension?

给你一囗甜甜゛ 提交于 2019-11-28 01:21:29

Note that @interface NSMutableArray (MyStuff) is a category and not a class extension. They are similar in this context, but actually do have quite a few different details.

You can't add storage to an existing class through either mechanism. You can use Associative References to associate data with an instance, though.

As you said, categories can add only methods to a class, not ivars. You could declare property and setProperty: methods in the category, but I'm not sure where you'd store the actual data of your pseudo-property.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!