re:My objectcontroller is loosing its moc, but only with certain timing

  • > This happens when I close a window in my app, but only if I close it
    > _very_ soon after it is opened.  If I leave the window open for a few
    > 100 ms then there is no problem.  My app is garbage collected.  The
    > exception is happening after windowWillClose.
    >
    > The culprit seems to be an NSObjectController in the nib.  At this
    > point, nothing in my nib nor code even uses this objectController.  I
    > can stop the exception by doing one of two things:
    >
    > a) remove it's binding to my document's moc.  Instead, I call
    > [myController setManagedObjectContext:...] in awakeFromNib.
    >
    > b) change the 'prepares content' checkbox from on to off and instead
    > call [myController fetchWithRequest:nil merge:NO error:&error] in
    > windowDidLoad.
    >
    > Anyone understand what's happening?  Does it sound like a Cocoa bug?

    That's pretty weird, and yes it sounds like a bug in NSObjectController.

    If you can make a sample Xcode project that reproduces the problem and
    attach it to a bugreport.apple.com bug that would be very helpful.

    - Ben
  • On 1/22/09 3:00 PM, Ben Trumbull said:

    >> This happens when I close a window in my app, but only if I close it
    >> _very_ soon after it is opened.  If I leave the window open for a few
    >> 100 ms then there is no problem.  My app is garbage collected.  The
    >> exception is happening after windowWillClose.
    >>
    >> The culprit seems to be an NSObjectController in the nib.  At this
    >> point, nothing in my nib nor code even uses this objectController.  I
    >> can stop the exception by doing one of two things:
    >>
    >> a) remove it's binding to my document's moc.  Instead, I call
    >> [myController setManagedObjectContext:...] in awakeFromNib.
    >>
    >> b) change the 'prepares content' checkbox from on to off and instead
    >> call [myController fetchWithRequest:nil merge:NO error:&error] in
    >> windowDidLoad.
    >>
    >> Anyone understand what's happening?  Does it sound like a Cocoa bug?
    >
    > That's pretty weird, and yes it sounds like a bug in NSObjectController.
    >
    > If you can make a sample Xcode project that reproduces the problem and
    > attach it to a bugreport.apple.com bug that would be very helpful.

    It repros surprisingly easily in a simple app:
    <rdar://6520501>

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
previous month january 2009 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Go to today