views:

373

answers:

1

Hi, I know there are other questions covering this topic, but none seem to fit exactly what I'm experiencing, hence the new question.

I have an app which is a UITabBarController, I have defined two subviews

Both tabs have their Class attribute in the Identity Inspector set to UINavigationController.

Both subviews are Class UIViewController and contain MKMapView objects.

I am trying to integrate Core Data with the objective being that I can use Core Data to store information about object I want to place on the map.

I have my UITabBarController defined as 'rootController' in my Delegate header file. I also have the managedObjectModel, managedObjectContext and persistentStoreCoordinator properties defined there.

In the Delegate implementation I have the standard accessor methods for the above properties and I have rootController defined as follows:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

[window addSubview:rootController.view];
[window makeKeyAndVisible];

}

In my view controllers for the child views, I have defined my managedObjectContext and synthesized it.

Now for my problem, I cannot get the compiler to allow me to reference the managedObjectContext in the App Delegate from the View Controllers.

I tried the following in the applicationDidFinishLaunching method:

firstView.managedObjectContext = self.managedObjectContext;

But I just get the following error:

Accessing unknown 'setManagedObjectContext:' class method

Can anyone help me figure this out?

Thanks


Update:

To add to my question, I'll head off some answers by providing more detail

I have an @Class declaration in my appdelegate.h file I have a #import statement in my appdelegate.m file for the firstView.h file I have declared my firstView as follows in my appdelegate.h file

FirstView *firstView;
+1  A: 

How is firstView declared and assigned?

It should be a reference to an object with a property named "managedObjectContext".

gerry3
Firstview is a uiviewcontroller. Mamagedobjectcontext is a property of the uiviewController
Griffo
@Gerry3 Did you mean how is it defined within the delegate?
Griffo
Yes, is it declared as a UIViewController or properly as your custom subclass of UIViewController that actually has the property?
gerry3
@Gerry3 Well the only reference to my FirstView code is via an @Class declaration in the delegate header. Do I need to import the header file from FirstView to be able to reference its managedObjectContext property?
Griffo
Correct, of course you need to import the class header.
gerry3
Hmmm, didn't have the source code in front of me earlier @Gerry3.I already have imported my firstView.h file in the delegate implementation file. Any other ideas?
Griffo
Is firstView declared as a UIViewController though or as your custom subclass? It has to be the latter. Can you edit your question and post more code (like the app delegate header)?
gerry3