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:

  • Add UICollectionView in UICollectionViewCell
  • Syncing a local sqlite file to iCloud
  • How to get Table Of Content in document view for Xcode 6.2?
  • Cut a UIImage into a circle Swift(iOS)
  • iOS7 - View under status bar - edgesForExtendedLayout not working
  • Render YpCbCr iPhone 4 Camera Frame to an OpenGL ES 2.0 Texture in iOS 4.3
  • 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.

    2 Solutions Collect From Internet About “Property cannot be found in forward class object”

    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
    

    Its not relevant to ur case but I was getting the same error. I googled for a solution but the problem was in my code. I was using different class object as I was copy pasting similar snippet of code in my project. So here is the problem that I had for the same error :

    For my classA , I had some code snippet like :

        ManagedObjectOfClassA * managedObjectOfClassA = [NSEntityDescription insertNewObjectForEntityForName:@"ManagedObjectOfClassA"                                                              inManagedObjectContext:managedObjectContext];
    
        managedObjectOfClassA.somePropertyA = sameValue; //somePropertyA is an attribute of ManagedObjectOfClassA
    

    And similar code for class B :

        ManagedObjectOfClassA *managedObjectOfClassB = [NSEntityDescription insertNewObjectForEntityForName:@"ManagedObjectOfClassB" inManagedObjectContext:managedObjectContext];
    
        managedObjectOfClassB.somePropertyB = someValue;////somePropertyB is an attribute of ManagedObjectOfClassB
    

    If u look closely, the mistake was in assigning the right entities to the corresponding objects in class B.

    So the problem is in code of class B. And the correct code would be :

    ManagedObjectOfClassB *managedObjectOfClassB = [NSEntityDescription insertNewObjectForEntityForName:@”ManagedObjectOfClassB” inManagedObjectContext:managedObjectContext];

    managedObjectOfClassB.somePropertyB.someValue;

    I hope that helps someone.