Re: KVO: NSObjectController won't contain File's Owner attribute
Re: KVO: NSObjectController won't contain File's Owner attribute
- Subject: Re: KVO: NSObjectController won't contain File's Owner attribute
- From: Fritz Anderson <email@hidden>
- Date: Tue, 2 May 2006 16:22:46 -0500
Sometimes rephrasing the question helps (or is at least more
dignified than tears and importunity)...
What I need to know is, how is the content object of a NIB-based
NSObjectController set? What would cause it not to be set?
The content object is a property of the document, and accessed
through an NSObjectController connected to the document object.
At windowControllerDidLoadNib: time,
po documentController
po [documentController content]
po [[documentController content] valueForKey: @"marineData"]
... all produce expected values. So does
po marineController
... at least to the extent of displaying an NSObjectController.
But...
po [marineController content]
... produces nil (Cannot access memory at address 0x0).
I wish I understood what was going on. Does anyone here know?
-- F
On 1 May 2006, at 5:13 PM, Fritz Anderson wrote:
I am having a pattern of errors in which an NSObjectController does
not point its content at an instance variable of the NIB's owner.
The summary of the NIB is
File's Owner is a MyDocument (NSPersistentDocument).
Document is an NSObjectController whose content outlet points to
File's Owner, and whose content type is class MyDocument.
Automatically prepares content.
MarineData is an NSObjectController, content type entity
ChannelizedData. Bound to property marineData of the Document
controller. Automatically prepares content. ManagedObjectContext
bound to File's Owner -> managedObjectContext.
There's an array controller bound to a property of MarineData, but
this seems not to be relevant.
There are 24 root-level objects in the NIB.
I added outlets for the Document and MarineData controllers so I
could observe them in the debugger.
Upon entering windowControllerDidLoadNib:, controllers Document and
MarineData are both NSObjectControllers. Document controller has
the content you'd expect.
MarineData controller has nil content (this is the surprise, and
the bug I'm prosecuting).
The application behaves as though MarineData has no content. The
underlying MyDocument has a marineData instance variable, and it is
non-nil. Intercepting the marineData accessor shows it is called
during initialization.
This is the case whether MyDocument.marineController has explicit
KV accessors or not.
This is part of a pattern, in that I've seen the same sort of
behavior before. The bug went away when I wiggled things around --
doing things like renaming instance variables. I don't remember
which of my changes corrected the problem, only that I was down to
desperate measures (i.e. wiggling things around).
The problem is probably conceptual on my part, in which case all
this detail is a red herring (except insofar as it narrows the
problem down to my missing something).
Can anyone help, please?
-- F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden