Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

ios - Property cannot be found in forward class object

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:

The actual error line:

for (DTContact *dtc in _dtContact.contact) {

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Try to insert this in your .h file:

#import DTContact.h

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...