KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was defining a NSString to use as error domain in NSError and was copying how ASIHttpRequest was doing there's. NSString* const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain"; I put the const in its own .h file // FPServerAPICoordinatorConstants.h #ifndef FirePlayer_FPServerAPICoordinatorConstants_h #define FirePlayer_FPServerAPICoordinatorConstants_h NSString* const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain"; #endif but when I included it in more than one .m SomeFile.m #import "FPServerAPICoordinatorConstants.h" SomeOtherFile.m #import "FPServerAPICoordinatorConstants.h" I got linker error 'duplicate symbol' ld: duplicate symbol _FPServerAPIErrorDomain in SomeFile.o and ....SomeOtherFile.o for architecture armv7 so I change the const to #define and it worked ok. // FPServerAPICoordinatorConstants.h #ifndef FirePlayer_FPServerAPICoordinatorConstants_h #define FirePlayer_FPServerAPICoordinatorConstants_h //THIS WAS TRIGGERING link errors //NSString* const FPServerAPIErrorDomain = @"FPServerAPIErrorDomain"; //working OK #define FPServerAPIErrorDomain @"FPServerAPIErrorDomain" #endif But is there a way to get the const in global space not to throw 'duplicate symbol'?
Tags (comma-separated)
Save Edits
Cancel