2

我最近开始了一个在 Mountain Lion 上运行的 Xcode 4.4 新项目。我有一个名为 的类TSTopChartManager,它位于我项目的 MainMenu nib 中。我还有一个名为 的数据容器PodcastShow,它基本上有一堆属性和一个从 Internet 获取图像的方法。这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)

我不知道为什么会这样。我以前没有见过这样的错误。我将如何解决它?有任何想法吗?谢谢!

对于好奇: 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
4

1 回答 1

11

可能PodcastShow.m不是构建阶段的一部分。在项目导航器中单击它,然后在文件信息中查看屏幕右侧。确保您的应用目标已勾选。

于 2012-07-26T22:13:01.403 回答