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?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
- how to find the index position of the ARRAY Where
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- didBeginContact:(SKPhysicsContact *)contact not in
- Custom Marker performance iOS, crash with result “
- Why is my library not able to expand on the CocoaP
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
andsetProperty:
methods in the category, but I'm not sure where you'd store the actual data of your pseudo-property.