Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefinition of as a different kind of symbol in Objective-C

Tags:

objective-c

We have a class WayPoint. But at some point, we decided to rename the class to Placemark. However, we don't really want to change the name of the class because it will result in a lot of modification of the existing code. Therefore, I added one line of typedef at the bottom of the header file and start using Placemark in any new code happily ever since.

@interface WayPoint : _WayPoint
@end
typedef WayPoint Placemark;

But there is still one thing that I don't understand. If I try to use the forward definition in some other header file. I can only used:

@class WayPoint;

If I use:

@class Placemark;

I will get the error message:

Redefinition of 'Placemark' as a different kind of symbol

Why?

like image 835
Yuchen Avatar asked Oct 29 '14 14:10

Yuchen


2 Answers

Not sure why can't you use Xcode's refactoring features (Simple Rename does it fast and easy). But if you really want to do this you may use something better then typedef:

@compatibility_alias Placemark WayPoint
like image 88
MANIAK_dobrii Avatar answered Jan 10 '23 17:01

MANIAK_dobrii


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

So error clearly indicates Redefinition of 'Placemark' as a different kind of symbol which means your class name and typedef alias are different symbol.

like image 45
Hussain Shabbir Avatar answered Jan 10 '23 15:01

Hussain Shabbir