Reputation: 767
I'm doing some tests with @compatibility_alias, and realized that:
With it we can change the name of our class, but compensating you can only access static methods (+).
My doubt is: @compatibility_alias can access instance methods (-)? or it is restricted only static methods (+)?
Upvotes: 0
Views: 175
Reputation: 53010
You don't access instance methods using a class name, but using an instance. So for example with:
@compatibility_alias BaArray NSMutableArray
there is no more need to access addObject:
via BaArray
than there is via NSMutableArray
. The above can be used as:
BaArray *ba = [BaArray new]; // allocates an NSMutableArray
[ba addObject:@42]; // adds an object to the NSMutableArray
The instance method call does not mention BaArray
or NSMutableArray
.
Note: this feature is not designed to "change the name of our class", but for situations where a class name has changed and there is a desire to use existing source which contains the old name.
HTH
Upvotes: 3