[MacRuby-devel] How to stop observing
Dave Baldwin
dave.baldwin at dsl.pipex.com
Thu Apr 29 11:33:21 PDT 2010
A common design pattern in cocoa seems to be to have a objc method along the lines:
- (void)dealloc {
// Stop observing the tool palette.
[[NSNotificationCenter defaultCenter] removeObserver:self name:SKTSelectedToolDidChangeNotification object:[SKTToolPaletteController sharedToolPaletteController]];
// Stop observing the document's canvas size.
[[self document] removeObserver:self forKeyPath:SKTDocumentCanvasSizeKey];
// memory management stuff removed...
}
- taken from the Sketch sample.
One way to handle this would be to add a finalizer method to act in place of the the dealloc, but is this the best or correct way to handle this?
Thanks,
Dave.
More information about the MacRuby-devel
mailing list