I have 2 sets of immutable / mutable types.
@class AAA; @class BBB; @class MutableAAA; @class MutableBBB; @interface AAA : NSObject @property (readonly,nonatomic,copy) BBB* bbb; @end @interface BBB : NSObject @property (readonly,nonatomic,copy) AAA* aaa; @end @interface MutableAAA : AAA @property (readwrite,nonatomic,copy) MutableBBB* bbb; @end @interface MutableBBB : BBB @property (readwrite,nonatomic,copy) MutableAAA* aaa; @end
Since Objective-C supports covariance of the return type, this is completely legal, but the problem is that the two classes reference each other, I donβt know how to tell the MutableBBB compiler MutableBBB subclass BBB before defining it.
Of course, I can fall back to the category to get around this, but I want to define them in the main module of the interface, because this is part of the important definition of the class, and not an additional method.
Clang is currently generating a warning. How can I do this without warning?
Update
My intention is a mutable class type to enable in-place editing on an object tree. readonly/readwrite doesn't matter. I think I have two options that I want to avoid.
- Use categories.
- Adding a separate modified version access option. (e.g. the
-mutableBytes method in NSMutableData )
I just want to know if there is some unknown function that I don't know yet that activates this cross-reference subclass.
source share