I have a document based app.
MyDocument.h has:
        IBOutlet        IKImageView *myIkView;

MyDocument.nib has an IKImageView  and an NSSlider with it's value bound to 
myIkView.rotationAngle.

Works perfectly.

But when I closed the window I got an exception complaining about some 
observers not beeing removed.
So I added:

- (void)windowWillClose:(NSNotification *)notification
{
        id f = [ ikView observationInfo ];
        NSString *oi = [ f description ];
        
        BOOL ok;
        NSString *obs = @"Observer:";
        NSString *kpa = @"Key path:";
        unsigned long long uuu;
        NSString *keyPath1;
        
        NSScanner *u = [ NSScanner scannerWithString: oi ];
        [ u setCharactersToBeSkipped: [ NSCharacterSet 
whitespaceAndNewlineCharacterSet ] ];
        
        ok = [ u scanUpToString: obs intoString: NULL ];
        ok = [ u scanString: obs intoString: NULL ];
        ok = [ u scanHexLongLong: &uuu ];
        ok = [ u scanUpToString: kpa intoString: NULL ];
        ok = [ u scanString: kpa intoString: NULL ];
        ok = [ u scanUpToString: @"," intoString: &keyPath1 ];
        [ myIkView removeObserver: (id)uuu  forKeyPath: keyPath1 ];
}

I have some nagging feeling that this is NOT the most straightforward way to 
get rid of this exception.

But:
After windowWillClose: has successfully finished without any exceptions I get 
an EXC_BAD_ACCESS which I don't know what to do about:

#0  0x00007fff83d6311c in objc_msgSend ()
#1  0x00007fff886d150e in -[NSKeyValueNestedProperty 
object:didRemoveObservance:recurse:] ()
#2  0x00007fff886d0d47 in -[NSObject(NSKeyValueObserverRegistration) 
_removeObserver:forProperty:] ()
#3  0x00007fff886d0c2b in -[NSObject(NSKeyValueObserverRegistration) 
removeObserver:forKeyPath:] ()
#4  0x00007fff83fd02e4 in -[NSBinder _updateObservingRegistration:] ()
#5  0x00007fff841c09a8 in -[NSBinder 
releaseConnectionWithSynchronizePeerBinders:] ()
#6  0x00007fff845964bd in -[NSValueBinder 
releaseConnectionWithSynchronizePeerBinders:] ()
#7  0x00007fff83faf556 in -[NSObject(_NSBindingAdaptorAccess) 
_releaseBindingAdaptor] ()
#8  0x00007fff8400798b in -[NSView _releaseBindingAdaptor] ()
#9  0x00007fff84006e09 in -[NSView _finalizeWithReferenceCounting] ()
#10 0x00007fff840064fc in -[NSView dealloc] ()
#11 0x00007fff840cef4f in -[NSControl dealloc] ()
#12 0x00007fff8560d246 in _CFAutoreleasePoolPop ()
#13 0x00007fff886d62f8 in -[NSAutoreleasePool drain] ()
#14 0x00007fff83fa27db in -[NSApplication run] ()
#15 0x00007fff83f9b468 in NSApplicationMain ()
#16 0x000000010000297e in main (argc=1, argv=0x7fff5fbff588) at 
/Volumes/เม่น/Users/gerriet/Source/Stuff 10.6.2/iMatsch Viewer/main.m:13


Obviously I am missing something fundamental how to properly close a window.
Any help much appreciated.

10.6.2;  garbage collection unsupported.


Kind regards,

Gerriet.


_______________________________________________

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

Reply via email to