2014-10-01 89 views
1

我有点迷路,为什么我得到这个错误。非常多,我抽象了一些代码来创建一个帮助类,让我可以重复使用通过我的应用程序使用的颜色。我不明白为什么我得到这个错误的原因是因为当我将我的类导入到我的NC Widget时,没有任何抱怨。但是,当我将我的类导入到我的TableViewController的基础TableViewController中时,出现此错误。 UIKit被添加到我的框架中,所以我不确定我做错了什么。Apple-Mach-O链接器错误UIKit iOS 8

#import <UIKit/UIKit.h> 

@interface ColorPalette : UIColor 

+(UIColor *)setColorRed; 
+(UIColor *)setColorBlue; 
+(UIColor *)setColorGreen; 
+(UIColor *)setColorOrange; 


@end 

而且

#import "ColorPalette.h" 

@implementation ColorPalette 

+(UIColor *)setColorRed{ 
    return [UIColor colorWithRed:204/255.0f green:25/255.0f blue:36/255.0f alpha:1.0f]; 
} 

+(UIColor *)setColorGreen{ 
    return [UIColor colorWithRed:29/255.0f green:156/255.0f blue:48/255.0f alpha:1.0f]; 
} 

+(UIColor *)setColorBlue{ 
    return [UIColor colorWithRed:67/255.0f green:174/255.0f blue:249/255.0f alpha:1.0f]; 
} 

+(UIColor *)setColorOrange{ 
    return [UIColor colorWithRed:237/255.0f green:145/255.0f blue:50/255.0f alpha:1.0f]; 
} 


@end 

所以,当我将其导入到我的表视图:

Undefined symbols for architecture i386: 
    "_OBJC_CLASS_$_ColorPalette", referenced from: 
     objc-class-ref in TableView.o 
ld: symbol(s) not found for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

顶部的.m的文件的TableView

#import "TableView.h" 
#import "ColorPalette.h" 

顶.H TableViewFile的

#import <UIKit/UIKit.h> 

@interface TableView : UIViewController <UITableViewDataSource, UITableViewDelegate> 
+0

显示你的TableView.m和.h文件的顶部 - 你在哪里导入类? – Undo 2014-10-01 14:50:03

+0

您是否正在导入'.m'文件而不是'.h'文件?你有两个互相导入的'.h'文件导致循环导入吗?您的'Tableview.m'文件是否列在Target - > Build Phases - > Compile Sources下? – JAL 2014-10-01 15:24:06

+0

@JAL我已经添加了文件的顶部。感谢您的目标 - >构建阶段提示!这似乎是。我想知道为什么当我创建文件时没有立即添加它。 – David 2014-10-01 15:48:42

回答

2

确保您的Tableview.m文件列在Target - > Build Phases - > Compile Sources下。