我最近在运行在Mountain Lion上的Xcode 4.4中启动了一个新项目。我有一个名为TSTopChartManager的类,该类位于项目的MainMenu笔尖中。我还有一个名为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


m:

#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

最佳答案

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

关于objective-c - Xcode 4.4中的体系结构x86_64的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11678776/

10-17 03:13