So, here is the solution I found ... turned out to be pretty simple as soon as you knew what to do. First rewrite '- (id) forwardingTargetForSelector: (SEL) aSelector' and return iVar:
- (id) forwardingTargetForSelector:(SEL)aSelector{ return iVar; }
When the runtime searches for a method and cannot find it, it will call this method to see if there is another object to forward the message to. Note that this method usually returns nil, and if you return nil here, your program will crash (which is the appropriate behavior).
The second part of the problem is to remove the compiler errors / warnings you get when you try to send a message that has not been announced. This is easy to do by declaring a category that you are not implementing.
@interface Class (iVarClassMethods) @propoperty (strong) Class *property1; ......more properties @end
Until you execute the implementation somewhere, aka @implementation Class (category) , the compiler will not complain (it is assumed that the implementation is somewhere.).
Now the only drawback that I see is that if you change any properties in the iVar Class interface, you need to make sure that you update all other classes that use the method described above, otherwise you will encounter when another class tries send what is now the wrong method (and the compiler will not warn you in advance). However, this can be obtained. You can declare protocols in categories. So instead, you create a separate protocol for the iVar class and move the methods / properties you want from the iVar class to the protocol.
@protocol iVarClassProtocol @propoperty (strong) Class *property1; ......more properties @end
Add this protocol to the iVar subclass so that it now detects these methods declared in the protocol.
@interface iVarClass <iVarClassProtocol> ....other methods/properties you don't need forwarded @end
Finally, just add the protocol to the category. Therefore, instead of the above category with explicit declarations, you will have:
@interface Class (iVarClassMethods) <iVarClassProtocol> @end
Now, if you need to change any properties / methods that you want, you will change them in the protocol. Then the compiler will warn you when you try to send the wrong method to the forwarding class.