4

我在 iOS 应用程序中使用 typedef NS_ENUM 并收到此错误:“链接器命令失败,退出代码 1”。通常这很容易解决,但这次我找不到解决方案......

这是我的 NS_Enum:

typedef NS_ENUM(NSInteger, MKIGridViewSelectionStyle)
            MKIGridViewSelectionStyle_SelectCellOnly = 1,
            MKIGridViewSelectionStyle_SelectCompleteRow = 2,
            MKIGridViewSelectionStyle_SelectCompleteColumn = 3;

编辑:

完整消息:

ld /Users/mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Products/Debug-iphoneos/GridViewTest.app/GridViewTest normal armv7s cd /Users/mki/Desktop/GridViewTest setenv IPHONEOS_DEPLOYMENT_TARGET 5.0 setenv PATH "/Applications /Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7s -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ iPhoneOS6.0。sdk -L/Users/mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Products/Debug-iphoneos -F/Users/mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Products/ Debug-iphoneos -filelist /Users/mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Intermediates/GridViewTest.build/Debug-iphoneos/GridViewTest.build/Objects-normal/armv7s/GridViewTest.LinkFileList -dead_strip - fobjc-arc -fobjc-link-runtime -miphoneos-version-min=5.0 -framework QuartzCore -framework AudioToolbox -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso /Build/Products/Debug-iphoneos/GridViewTest.app/GridViewTest应用程序/GridViewTest应用程序/GridViewTestLinkFileList -dead_strip -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=5.0 -framework QuartzCore -framework AudioToolbox -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/mki/Library/Developer/Xcode/DerivedData /GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Products/Debug-iphoneos/GridViewTest.app/GridViewTestLinkFileList -dead_strip -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=5.0 -framework QuartzCore -framework AudioToolbox -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/mki/Library/Developer/Xcode/DerivedData /GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Products/Debug-iphoneos/GridViewTest.app/GridViewTest

重复符号 _MKIGridViewSelectionStyle_SelectCellOnly 在:/Users/mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Intermediates/GridViewTest.build/Debug-iphoneos/GridViewTest.build/Objects-normal/armv7s/MKIViewController.o /Users/ mki/Library/Developer/Xcode/DerivedData/GridViewTest-esfqwoooiarqpchfzsazwbgckmso/Build/Intermediates/GridViewTest.build/Debug-iphoneos/GridViewTest.build/Objects-normal/armv7s/MKIGridView.o ld:架构armv7s的3个重复符号clang:错误: 链接器命令失败,退出代码为 1(使用 -v 查看调用)

迈克

4

1 回答 1

11

您忘记在值定义周围使用大括号。

typedef NS_ENUM(NSInteger, MKIGridViewSelectionStyle) {
        MKIGridViewSelectionStyle_SelectCellOnly = 1,
        MKIGridViewSelectionStyle_SelectCompleteRow = 2,
        MKIGridViewSelectionStyle_SelectCompleteColumn = 3
};
于 2012-12-03T09:30:53.000 回答