Search Results

Search found 2 results on 1 pages for 'yahuie'.

Page 1/1 | 1 

  • Core-Data Can't pass managedObjectContext from app delegate to view controller

    - by yahuie
    I'm making a core-data application that is view based. I can create the managedObjectContext and 'use' it in the app delegate, but can not pass it to the mainviewcontroller. Probably something simple, but I can't find the problem after looking for quite a while. The managedObjectModel is nil in the mainviewcontroller. The log and error is here: 2010-06-02 11:01:10.504 TestCoreData[404:207] Could not make MOC in MainViewController implementation. 2010-06-02 11:01:10.505 TestCoreData[404:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'Shelf'' 2010-06-02 11:01:10.506 TestCoreData[404:207] Stack: ( 30864475, 2452296969, 28852395, 12038, 3217218, 10258, 2700679, 2738614, 2726708, 2709119, 2736225, 38960473, 30649216, 30645320, 2702869, 2740143, 9704, 9558 ) (gdb) Code for app delegate here: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil]; self.mainViewController = aController; [aController release]; NSLog(@"before did finish launching"); if (self.managedObjectContext == nil) { NSLog(@"Could not make MOC in TestCoreDataAppDelegate implementation."); } //Just to see if I can access the here. NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Shelf" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; if (!entity) { NSLog(@"No Entity in TestCoreDataAppDelegate didfinishlaunching"); } NSLog(@"passed did finish launching"); NSManagedObjectContext *context = [self managedObjectContext]; self.mainViewController.view.frame = [UIScreen mainScreen].applicationFrame; self.mainViewController.managedObjectContext = context; [context release]; [window addSubview:[mainViewController view]]; [window makeKeyAndVisible]; return YES; } Code in MainViewController here: @implementation MainViewController @synthesize managedObjectContext; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { NSLog(@"Could not make MOC in MainViewController implementation."); } NSFetchRequest* request = [[NSFetchRequest alloc] init]; NSEntityDescription* entity = [NSEntityDescription entityForName:@"Shelf" inManagedObjectContext:self.managedObjectContext]; [request setEntity:entity]; } Thanks.

    Read the article

  • Deleted nib still displayed when controller is pushed

    - by yahuie
    I have an application with a UINavcontroller under a tab bar controller. To create the navigation model I want, I push a container UIView object onto the stack to manage additional views(Thanks Frank). When I created the container class, an associated nib file was created along with it. I at first used that nib file, but it turned out it was better not to. So I deleted the nib (and selected 'also move to trash'). The problem is that it still shows up when I push its view controller onto the stack. I have tried emptying the cache in xcode and restarting xcode. What am I missing?

    Read the article

1