views:

75

answers:

1

I am following apples Core Data Utility tutorial from http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreDataUtilityTutorial/Articles/00_introduction.html

I have only just started it and have already encountered an error (more than likely my error, not anyone else's).

Given the code

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <objc/objc-auto.h>

NSManagedObjectModel *managedObjectModel();


int main (int argc, const char * argv[]) {
    objc_startCollectorThread();

    return 0;
}

NSManagedObjectModel *managedObjectModel() {

    static NSManagedObjectModel *mom = nil;
    if(mom != nil){
        return mom;
    }
    mom = [[NSManagedObjectModel alloc] init];
    // implimentation continues
    return mom;
}

I get the error:

"_OBJC_CLASS_$_NSManagedObjectModel", referenced from: objc-class-ref-to-NSManagedObjectModel in CoreDataUtility.o

I am guessing that the issue is caused by my forward declaration of the managedObjectModel() function, but I cannot solve as to why I am getting the issue I am.

+2  A: 

The forward decleration looks all right. It matches that provided by Apple.

Most likely, the error is caused because the Core Data Framework is not added to the project.

TechZen
Thank you, exactly the hint I needed.
Mick Walker
Linker errors seem to be a pretty common hangup for folks trying out a new technology, because they forgot to link against the right framework. You're in good company, Mick :)
Alex Martini