2

私は最近、MountainLionで実行されているXcode4.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)

なぜこれが起こっているのか分かりません。私はこれまでこのようなエラーを見たことがありません。どうすれば修正できますか?何か案は?ありがとうございました!

好奇心旺盛な方へ: PodcastShow私のアプリではデータコンテナとして扱われます。いくつかのプロパティと2つのメソッドがあります。次の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
4

1 に答える 1

11

おそらくPodcastShow.mビルドフェーズの一部ではありません。プロジェクトナビゲータでそれをクリックし、ファイル情報の画面の右側を見てください。アプリのターゲットがチェックされていることを確認してください。

于 2012-07-26T22:13:01.403 に答える