私は最近、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