Re: crash when using notification center and self
Re: crash when using notification center and self
- Subject: Re: crash when using notification center and self
- From: j o a r <email@hidden>
- Date: Tue, 6 Jun 2006 18:10:44 +0200
On 6 jun 2006, at 17.56, Bill Bumgarner wrote:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"MBModelStateChanged" object:self
userInfo:info];
results in a SIGSEGV
My model is going to post notifications which the controller picks up
- I'm calling that code from the model and I have multiple models
so I
need to be able to pay attention to only the right one at the right
time.
Is it wrong to pass "self" as the object when posting a notification?
Nope -- self works fine. The 'object:' parameter is used to only
notify observers of that specific object for that specific
notification (or observers that are interested in all instances of
the notification).
Likely, you have registered an observer that was observing just
notifications to 'self' that was released without first being
removed from the notification center as an observer.
The notification center does not retain observers and, therefore,
if an observer is released without first being removed as an
observer from the notification center, you'll see crashes just like
this.
...and using NSZombieEnabled is probably the most effective way to
track down where the problem is.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden