• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Binding and Observers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding and Observers


  • Subject: Binding and Observers
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Tue, 8 Dec 2009 17:17:41 +0700

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Binding and Observers
      • From: mmalc Crawford <email@hidden>
  • Prev by Date: Re: NSDecimal chokes on very small numbers
  • Next by Date: Re: Tracking Multiple Touches For Appropriate Label
  • Previous by thread: Re: NSDecimal chokes on very small numbers
  • Next by thread: Re: Binding and Observers
  • Index(es):
    • Date
    • Thread