Overriding as another character in Objective-C

We have a WayPoint class. But at some point, we decided to rename the class to Placemark . However, we do not want to change the name of the class, because this will lead to a big change in the existing code. So I added one line of typedef at the bottom of the header file and started using Placemark in any new code happily ever since.

 @interface WayPoint : _WayPoint @end typedef WayPoint Placemark; 

But there is one more thing that I do not understand. If I try to use forward definition in another header file. I can only use:

 @class WayPoint; 

If I use:

 @class Placemark; 

I will get the error message:

Overriding "tags" as another character

Why?

+5
source share
2 answers

Not sure why you can't use Xcode's refactoring functions (simple renaming makes it quick and easy). But if you really want to do this, you can use something better than typedef:

 @compatibility_alias Placemark WayPoint 
+6
source

Since typedef Placemark is an alias and you are trying to use it as a character class.

Thus, the error clearly indicates Overriding the "label" as a different character, which means that your class name and typedef alias are a different character.

+5
source

Source: https://habr.com/ru/post/1205781/


All Articles