[英]Apple Macho Linker Error Xcode
嗨,我正在創建動態表格視圖,並嘗試從其他文件中存儲的方法中上傳信息。 當我嘗試測試是否正在獲取信息時,出現Macho Linker錯誤
架構i386的未定義符號:“ _ OBJC_CLASS _ $ _ FlickrFetcher”,引用自:MyTableViewController.o中的objc-class-ref ld:架構i386找不到符號
這是我添加的導致問題的代碼。
FlickerFetcher.h這具有我的tableViewController調用topPlaces的方法
@interface FlickrFetcher : NSObject
+ (NSArray *)topPlaces;
+ (NSArray *)photosInPlace:(NSDictionary *)place maxResults:(int)maxResults;
+ (NSURL *)urlForPhoto:(NSDictionary *)photo format:(FlickrPhotoFormat)format;
@end
TableViewController文件。 我認為問題是在setter Brain中發生的,因為我懶惰地將其設置為無效,因為在添加代碼之前代碼運行正常,因為沒有對象但它在運行,所以NSlog返回NUll,然后當我將setter設置為無效時,我得到了Macho Linker錯誤。
#import "MyTableViewController.h"
#import "FlickrFetcher.h"
@interface MyTableViewController ()
@property (nonatomic, strong) FlickrFetcher* brain;
@end
@implementation MyTableViewController
@synthesize brain= _brain;
//Error occured after I added this setter
-(FlickrFetcher*) brain
{
if (!_brain) _brain= [[FlickrFetcher alloc] init];
return _brain;
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
//use a class method call since this is a class method
NSLog(@"Class = %@", [self.brain class]);
NSLog(@"Array = %@", [[self.brain class] topPlaces]);
}
我發現了錯誤,結果是文件FlickrFetcher尚未編譯或未在編譯列表中,我通過在導航菜單中單擊我的項目,進入目標並單擊我的應用程序,進入構建階段然后添加文件來解決此問題。在編譯源中。 希望對這個問題有幫助的人
objc-class-ref
部分包含您的應用程序使用的類信息。 它可以找到MyTableViewController
,但是找不到FlickrFetcher
類信息。 因此問題在於FlickrFetcher
類沒有添加到編譯拱門中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.