0
我試圖創造一些字符串常量,所以我有以下幾點:鏈接錯誤值
Constants.h
extern NSString* const CONSTANT_ONE;
Constants.m
NSString *const CONSTANT_ONE = @"CONSTANT_ONE";
SomeOtherFile.m
#import "Constants.h"
... snip
NSString* something = CONSTANT_ONE;
Constants.m列在目標構建階段的「Compile Sources」位中,當我查看側邊欄的「Target Membership」部分時,它是目標的成員。
當我嘗試編譯我得到這樣一個錯誤:
Undefined symbols for architecture i386:
"_CONSTANT_ONE", referenced from:
-[SomeOtherFile someMethod:] in SomeOtherFile.o
我想我可能在這裏誤解的東西基本的 - 任何人都可以幫我這個錯誤嗎?
你在這裏看起來是正確的。鏈接器錯誤可能難以追查。你能否發佈一些有問題的實際文件,以便我們能夠更好地幫助你? –