[MacRuby-devel] [MacRuby] #484: scoping issues with notification center

MacRuby ruby-noreply at macosforge.org
Sat Dec 5 16:18:33 PST 2009


#484: scoping issues with notification center
-------------------------------------+--------------------------------------
 Reporter:  mattaimonetti@…          |        Owner:  lsansonetti@…        
     Type:  defect                   |       Status:  closed               
 Priority:  blocker                  |    Milestone:                       
Component:  MacRuby                  |   Resolution:  invalid              
 Keywords:                           |  
-------------------------------------+--------------------------------------

Comment(by lsansonetti@…):

 It's actually documented.

 http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html

 "Important: The notification center does not retain its observers,
 therefore, you must ensure that you unregister observers (using
 removeObserver: or removeObserver:name:object:) before they are
 deallocated. (If you don't, you will generate a runtime error if the
 center sends a message to a freed object.)"

 MacRuby uses Objective-C in GC mode so retain will not help since it's a
 no-op. You must keep a reference to the observer by yourself. Typically
 this isn't such a problem in Cocoa apps since the observer is generally a
 controller object (self). Maybe you should re-design your program.

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/484#comment:3>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list