1

NSURLConnections に関するデータを保持するために、非常に単純なカスタム クラスを作成しました。これは実際にはモデルにすぎません。目的は、それらの配列、ConnectionInfo オブジェクトの配列を持つことです。

@interface ConnectionInfo : NSObject

@property NSString *connectionDescription;
@property int *campaignID;
@property int *requestType; //0 - Score, 1 - Image

@end

とてもシンプルなので、独自のファイルに入れることは気にしていません。ビューコントローラーの一番上にあるだけです。

とにかく、Xcode では問題はありませんが、このクラスのインスタンスを作成したい場合は、

ConnectionInfo *thisConnection = [[ConnectionInfo alloc] init];

以下の2つのエラーがスローされます。

アーキテクチャ i386 の未定義シンボル: "_OBJC_CLASS_$_ConnectionInfo"、参照元: ServerTestViewController.o ld の objc-class-ref: アーキテクチャ i386 のシンボルが見つかりません。clang: エラー: リンカ コマンドが終了コード 1 で失敗しました (使用 -v呼び出しを見るために)

私が Stackoverflow について調べたものはすべて、インポートされたライブラリに問題がある人に関するものですが、これは私自身のカスタム クラスです。

4

1 に答える 1

4

You're missing the implementation for the class, create one as follows

@implementation ConnectionInfo
@end

Why is this needed?

All you had done previously is declare the class interface. All this does is inform the user of the class (and the compiler) what to expect within the implementation. It does not declare how the class works. Without an implementation, you don't have a class to use!

Why is the implementation empty?

You may think putting a blank implementation in is pointless. What this will do is inform the compiler how to create an object. Whilst your implementation does nothing, you inherit from NSObject, which has a lot to do with object creation. Also, with the latest Xcode, you don't need to manually @synthesize your properties, so these are also set up for you automatically when you declare your @implementation.

于 2013-01-28T11:00:31.717 に答える