81

私はこのチュートリアルを自分のアプリに適応させていますが、最後の 1 つのエラーにまで煮詰めてしまい、それが私の足を止めています。プログラムは別のファイルでプロパティを見つけることができませんが、そのプロパティは明確に定義されています。問題のコードは次のとおりです。

実際のエラー行:

for (DTContact *dtc in _dtContact.contact) {

ファイルの .h と問題の項目:

#import <UIKit/UIKit.h>

@class XMLTestViewController;
@class DTCXMLResponse;

@interface XMLTestController : UIViewController{
    UIWindow *window;
    XMLTestViewController *viewController;
    DTCXMLResponse *_dtContact;
}


@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet XMLTestViewController *viewController;
@property (nonatomic, retain) DTCXMLResponse *dtContact;

@property (nonatomic, retain) IBOutlet UIButton *mybutton;
-(IBAction)buttonClicked;

@end

_dtContact.contact に問題があります。ファイル DTCXMLResponse で連絡先が見つかりません。.h ファイルと .m のセクションは次のとおりです。

.h

#import <Foundation/Foundation.h>

@interface DTContactXMLResponse : NSObject {
    NSMutableArray *_contact;
}

@property (nonatomic, retain) NSMutableArray *contact;

@end

.m

#import "DTCXMLResponse.h"

@implementation DTContactXMLResponse
@synthesize contact = _contact;

- (id)init {

    if ((self = [super init])) {
        self.contact = [[NSMutableArray alloc] init];
    }
    return self;

}

@end

それで、それがあります。ご覧のとおり、DTCXMLResponse.h に「contact」プロパティがあり、.m にリンクされています。

4

2 に答える 2

189

このエラーは通常、Xcodeがシンボルを認識できないことを示しています。これはDTContactだと思います。

これを.hファイルに挿入してみてください。

#import DTContact.h
于 2011-12-20T15:13:52.160 に答える