我最近在Mountain Lion上运行了Xcode 4.4的新项目。我有一个名为TSTopChartManager
的类,它位于我项目的MainMenu笔尖中。我还有一个名为PodcastShow
的数据容器,它基本上有一堆属性和一个从互联网上获取图像的方法。这就是TSTopChartManger
的样子......
.h文件......
#import <Foundation/Foundation.h>
#import "PodcastShow.h"
@interface TSTopChartManager : NSObject
@property NSMutableArray *topPodcasts;
@end
.m文件:
#import "TSTopChartManager.h"
@implementation TSTopChartManager
-(id) init
{
if (self)
{
/*PodcastShow *myShow = [[PodcastShow alloc] init];
myShow.title = @"This is a show";*/
}
return self;
}
@end
现在,它完美运行。但是当我在init方法中删除块注释时就像这样......
if (self)
{
PodcastShow *myShow = [[PodcastShow alloc] init];
myShow.title = @"This is a show";
}
我收到以下错误..
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_PodcastShow", referenced from:
objc-class-ref in TSTopChartManager.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我不知道为什么会这样。我以前没见过这样的错误。我该怎么办呢?有任何想法吗?谢谢!
对于好奇:
{app}中将PodcastShow
视为数据容器。它有一些属性和两种方法。这是PodcastShow
的样子:
·H:
#import <Foundation/Foundation.h>
@interface PodcastShow : NSObject
{
NSString *title;
NSString *network;
NSString *imageURL;
NSImage *image;
NSString *link;
NSString *description;
}
-(void) fetch;
@property (strong, readwrite) NSString *title;
@property (strong, readwrite) NSString *network;
@property (strong, readwrite) NSString* imageURL;
@property (strong) NSImage *image;
@property (strong, readwrite) NSString *identification;
@property (strong, readwrite) NSString *link;
@property (strong, readwrite) NSString *description;
@end
米:
#import "PodcastShow.h"
@implementation PodcastShow
-(id) init
{
if (self)
{
NSLog(@"initilized");
}
return self;
}
-(void) fetch
{
[NSThread detachNewThreadSelector:@selector(getImageFromInternet) toTarget:self withObject:nil];
}
-(void) getImageFromInternet
{
self.image = [[NSImage alloc] initWithContentsOfURL:[NSURL URLWithString:self.imageURL]];
}
@end
答案 0 :(得分:11)
可能PodcastShow.m
不是构建阶段的一部分。在项目导航器中单击它,然后在文件信息中查看屏幕右侧。确保勾选了您的应用目标。