Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add properties to NSMutableArray via category extension?

I know that I can "subclass" an NSMutableArray using "category extensions," i.e. @interface NSMutableArray (MyExtension), to add new functions to the class. However, is there a way using category extensions to also add new properties to the extension?

like image 671
Jason Avatar asked Nov 15 '22 06:11

Jason


1 Answers

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.

like image 148
bbum Avatar answered Mar 06 '23 08:03

bbum