我有持有數量的ivars類:
// Answer.h
#import <Foundation/Foundation.h>
@interface Answer : NSObject{
@public
int firstNumber;
int secondNumber;
char myOperator;
}
@end
我嘗試訪問這裏的代碼
numberGroup->firstNumber = arc4random() % 1;
numberGroup->secondNumber = arc4random() % 10;
numberGroup->myOperator = arc4random() % 4;
,我得到這個錯誤:
Ld /Users/jack/Library/Developer/Xcode/DerivedData/PowerBuilders-emehzkfcgntrhofxhvurovjmnugn/Build/Products/Debug-iphonesimulator/PowerBuilders.app/PowerBuilders normal i386 cd "/Users/jack/Desktop/Xcode/Assorted Apps/PowerBuilders" setenv MACOSX_DEPLOYMENT_TARGET 10.6 setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/jack/Library/Developer/Xcode/DerivedData/PowerBuilders-emehzkfcgntrhofxhvurovjmnugn/Build/Products/Debug-iphonesimulator -F/Users/jack/Library/Developer/Xcode/DerivedData/PowerBuilders-emehzkfcgntrhofxhvurovjmnugn/Build/Products/Debug-iphonesimulator -filelist /Users/jack/Library/Developer/Xcode/DerivedData/PowerBuilders-emehzkfcgntrhofxhvurovjmnugn/Build/Intermediates/PowerBuilders.build/Debug-iphonesimulator/PowerBuilders.build/Objects-normal/i386/PowerBuilders.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/jack/Library/Developer/Xcode/DerivedData/PowerBuilders-emehzkfcgntrhofxhvurovjmnugn/Build/Products/Debug-iphonesimulator/PowerBuilders.app/PowerBuilders
Undefined symbols for architecture i386:
"_OBJC_IVAR_$_Answer.firstNumber", referenced from: -[ViewController lesson1] in ViewController.o "_OBJC_IVAR_$_Answer.myOperator", referenced from: -[ViewController lesson1] in ViewController.o "_OBJC_IVAR_$_Answer.secondNumber", referenced from: -[ViewController lesson1] in ViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
你意識到'a4r()%1'將始終爲0,對嗎? – Kevin
您是否嘗試過清潔項目? – Kevin
是的,我已經嘗試清理該項目,但沒有抓住第二個。謝謝 – TheLivingForce