Re: NSWindowController for Prefs XIB Question (Core Data involved) - Solved
Folks; I have figured at least part of this out. My PrefsController had an instance variable that was of a class from the Core Data Model. Since the MOC was not available until after the initWithWindow, anything derived from NSManagedObject is not valid. Once I removed this instance variable the window now now opens. Hopefully this is helpful to someone else…. Steve On May 20, 2010, at 10:08 PM, Steve Cronin wrote: Folks; I have a feeling that this is an embarrassing one so try and go easy on me… XC 3.2.2 I have a main nib that opens a window and that works fine. I used to have an NSPanel in this nib to handle preferences. I've decided it's a good idea to split the nib into two different nibs: the main nib and a preferences nib. I've looked over the Sketch project and used it as a model. I've also read over the Document-Based App Overview FAQ I've added a window nib to the project and then subclassed a NSWindowController. I've made the xib's files owner this window controller At this point I can get a simple empty window to open just fine. However, I'm using CoreData and I want to pass the existing MOC to the pref window: I have added an array controller to the pref nib with its MOC set to files owner's MOC in IB. The controller manages an entity not a mutable dictionary. MOC is a synthesized property of the PrefController (the windowController mentioned above). if (!prefPanelController) { prefPanelController = [[PreferencesController alloc] initWithWindowNibName:@testPref]; [prefPanelController setManagedObjectContext:[self managedObjectContext]]; } [prefPanelController showWindow:sender]; No window opens and I get a console error: Cannot perform operation without a managed object context Could someone give me the gentle head slap I need here? Steve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/billy%40deviltrain.co.uk This email sent to bi...@deviltrain.co.uk ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindowController for Prefs XIB Question (Core Data involved)
On May 20, 2010, at 20:08, Steve Cronin wrote: if (!prefPanelController) { prefPanelController = [[PreferencesController alloc] initWithWindowNibName:@testPref]; [prefPanelController setManagedObjectContext:[self managedObjectContext]]; } [prefPanelController showWindow:sender]; No window opens and I get a console error: Cannot perform operation without a managed object context This could well be a time, or order of things happening, problem. At the time the nib is loaded, the MOC property of the controller hasn't been set yet, so the array controller fetches a nil MOC, and throws an exception which aborts the rest of the loading process. You probably need to write a custom initializer for your custom window controller and pass the MOC as a parameter, instead of trying to set it later. That's my theory, anyway. Note you can figure this out by writing your own getter method, setting a breakpoint in it and see if it's called while the MOC value is still nil. Also make sure you (always) have a breakpoint on objc_exception_throw, so that you see the backtrace of exceptions at the time they occur. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindowController for Prefs XIB Question (Core Data involved)
Folks; This one is driving me mad! I'm trying to bust up an overly complicated xib into 2 xibs - the main xib and a preference xib I've started completely over trying to implement a pref xib -- no CoreData just bare bones…. I have created a brand new subclass of NSWindowController: Pref2Controller there is not a single line of code in this object nor any instance variables. I have created a brand new xib file: ptest XCode creates the xib with a FilesOwner, FirstResponder, Application, and Window (set to releaseOnClose and visibleAtLaunch) I have set the FilesOwner to be an instance of Pref2Controller (using IB) I have set the window outlet of the FilesOwner to point to the NSWindow object (using IB) These two are the only changes I've made to ptest.xib When I use this code in the appDelegate: - (IBAction) configure:(id)sender { if (!prefPanelController) { prefPanelController = [[Pref2Controller alloc] initWithWindowNibName:@ptest]; } [prefPanelController showWindow:sender]; } The new ptest.xib window will open once but never again if I close it. this is true regardless of whether I set the window to releaseOnClose or not this is also true regardless of whether I have hooked up the window outlet or not logging [pController window] shows (null) regardless of whether I have outlet assigned or not as well as regardless of whether prefPanelController already exists or has just been alloc'ed and init'ed.. What I am just not understanding here? Please? Steve On May 20, 2010, at 10:08 PM, Steve Cronin wrote: Folks; I have a feeling that this is an embarrassing one so try and go easy on me… XC 3.2.2 I have a main nib that opens a window and that works fine. I used to have an NSPanel in this nib to handle preferences. I've decided it's a good idea to split the nib into two different nibs: the main nib and a preferences nib. I've looked over the Sketch project and used it as a model. I've also read over the Document-Based App Overview FAQ I've added a window nib to the project and then subclassed a NSWindowController. I've made the xib's files owner this window controller At this point I can get a simple empty window to open just fine. However, I'm using CoreData and I want to pass the existing MOC to the pref window: I have added an array controller to the pref nib with its MOC set to files owner's MOC in IB. The controller manages an entity not a mutable dictionary. MOC is a synthesized property of the PrefController (the windowController mentioned above). if (!prefPanelController) { prefPanelController = [[PreferencesController alloc] initWithWindowNibName:@testPref]; [prefPanelController setManagedObjectContext:[self managedObjectContext]]; } [prefPanelController showWindow:sender]; No window opens and I get a console error: Cannot perform operation without a managed object context Could someone give me the gentle head slap I need here? Steve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindowController for Prefs XIB Question (Core Data involved)
On May 20, 2010, at 23:51, Steve Cronin wrote: I have created a brand new xib file: ptest XCode creates the xib with a FilesOwner, FirstResponder, Application, and Window (set to releaseOnClose and visibleAtLaunch) ... The new ptest.xib window will open once but never again if I close it. this is true regardless of whether I set the window to releaseOnClose or not *Do not* set visibleAtLaunch to YES. You want the window to be shown via the window controller's 'showWindow:' method, not have it appear before that under its own initiative. There are *very* few situations where setting visibleAtLaunch is appropriate. *Do not* set releaseOnClose to YES in this case. Once the window is released, you need to have the nib be re-loaded to get a new instance, which means you need to destroy and recreate your window controller too. (You could do that, but it's easier to leave both the window controller and the window in existence.) You'd normally want releaseOnClose for something like a document window -- when it's gone, so is the document and its window controller -- but not for a window belonging to a persistent window controller. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSWindowController for Prefs XIB Question (Core Data involved)
On May 21, 2010, at 12:09 AM, Quincey Morris wrote: On May 20, 2010, at 20:08, Steve Cronin wrote: if (!prefPanelController) { prefPanelController = [[PreferencesController alloc] initWithWindowNibName:@testPref]; [prefPanelController setManagedObjectContext:[self managedObjectContext]]; } [prefPanelController showWindow:sender]; No window opens and I get a console error: Cannot perform operation without a managed object context This could well be a time, or order of things happening, problem. At the time the nib is loaded, the MOC property of the controller hasn't been set yet, so the array controller fetches a nil MOC, and throws an exception which aborts the rest of the loading process. You probably need to write a custom initializer for your custom window controller and pass the MOC as a parameter, instead of trying to set it later. That's my theory, anyway. This specific issue is unlikely the case, as NSWindowController lazily loads its nib--i.e. not until something asks for the window object. The nib would not be loaded on initialization, unless subclassed to specifically do so. Anyway, Steve, if you want useful answers, you must give specific information using specific language. However, I'm using CoreData and I want to pass the existing MOC to the pref window: I have added an array controller to the pref nib with its MOC set to files owner's MOC in IB. How did you set the MOC? Using bindings or outlet? If you used outlet, I am sorry to say, that is very wrong. In any case, you are being told the problem--your MOC is not being properly set. Debug appropriately. Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSWindowController for Prefs XIB Question (Core Data involved)
Folks; I have a feeling that this is an embarrassing one so try and go easy on me… XC 3.2.2 I have a main nib that opens a window and that works fine. I used to have an NSPanel in this nib to handle preferences. I've decided it's a good idea to split the nib into two different nibs: the main nib and a preferences nib. I've looked over the Sketch project and used it as a model. I've also read over the Document-Based App Overview FAQ I've added a window nib to the project and then subclassed a NSWindowController. I've made the xib's files owner this window controller At this point I can get a simple empty window to open just fine. However, I'm using CoreData and I want to pass the existing MOC to the pref window: I have added an array controller to the pref nib with its MOC set to files owner's MOC in IB. The controller manages an entity not a mutable dictionary. MOC is a synthesized property of the PrefController (the windowController mentioned above). if (!prefPanelController) { prefPanelController = [[PreferencesController alloc] initWithWindowNibName:@testPref]; [prefPanelController setManagedObjectContext:[self managedObjectContext]]; } [prefPanelController showWindow:sender]; No window opens and I get a console error: Cannot perform operation without a managed object context Could someone give me the gentle head slap I need here? Steve ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com