在前向类对象中找不到属性 [英] Property cannot be found in forward class object

查看:188
本文介绍了在前向类对象中找不到属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在适应本教程到我的应用程序,我将其归结为最后一个错误,这使我停滞不前.程序无法在另一个文件中找到属性,但是该属性已明确定义.这是有问题的代码:

I'm adapting This tutorial to my app, and I've got it boiled down to one last error, which is stopping me in my tracks. The program is unable to find a property in another file, but that property is clearly defined. Here is the code in question:

实际错误行:

for (DTContact *dtc in _dtContact.contact) {

文件和相关项目的.h:

the .h for the file, and items in question:

#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部分:

It's having issues with the _dtContact.contact. It can't find the contact in the file DTCXMLResponse. Here is the .h file and the section of the .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中设置了联系人",并在.m中进行了链接.

So theres that. As you can see, I have 'contact' propertied in the DTCXMLResponse.h, and linked in the .m.

推荐答案

此错误通常指出Xcode无法识别您的符号. 我可以假设这是DTContact.

This error usually points out that Xcode can not recognize your symbol. I can assume this is DTContact.

尝试将其插入您的.h文件:

Try to insert this in your .h file:

#import DTContact.h

这篇关于在前向类对象中找不到属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆