Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5849187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:57:51+00:00 2026-05-22T12:57:51+00:00

I have a document-based application with a view controller that contains a table, array

  • 0

I have a document-based application with a view controller that contains a table, array controller and add/remove buttons. I have bound the Managed Object Context to File’s Owner (myViewController) and established property/synthesize commands for myMOC.

My issue is how to set the managed object context from within the view controller. I wrote…

NSWindow *myWindow = [[self view] window];
NSWindowController *myWindowController = [myWindow windowController];
id myDoc = [myWindowController document];

self.myMOC = [myDoc managedObjectContext];

However, calling that from within awakeFromNib or init, generates a nil value for myWindow. Any help is appreciated. Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:57:52+00:00Added an answer on May 22, 2026 at 12:57 pm

    I’m assuming that myView is in its own nib when you load it and then you’re adding the view to a window that’s created in a different nib due to myViewController being the file’s owner. Is that correct? If so, [[self view] window] should be returning nil since the view hasn’t been added to a window when either awakeFromNib or init get called. You would need to run myMOC set-up code after myView has been added to the window. Try breaking the above code out into a -setupMOC method and call it after you add the view to the window or superview. If you’re doing it right away you might also be able to get away with calling [self performSelector:@selector(setupMOC) withObject:nil afterDelay:0.0] in awakeFromNib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a non document-based Core Data application. There's an NSTreeController that manages a
I have a document-based Cocoa application that has to start up a sub-process before
Environment: xcode 3.2.1, document-based core-data application. I have a document-based cocoa app which uses
My document-based Cocoa application uses a NSOutlineView/NSTreeController combo, bound to the document's Core Data
I have a Cocoa document-based app that (currently at least) functions as a basic
I have a document based application running with core data. The object model has
I have an document-based Cocoa application with a TextView and I would like to
I am working on a Cocoa document based application. I have a menu item
I've put together an app that uses a table view and navigation controller to
An existing document based application that saves and loads it's data using NSKeyedArchiver /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.