Notifications and memory management
Notifications and memory management
- Subject: Notifications and memory management
- From: Jay Kuri <email@hidden>
- Date: Sat, 30 Mar 2002 12:45:38 -0600
Hi there,
I have a question regarding Notifications. I have scoured the docs but
I have not found an answer to this one.
When one of my objects sends a notification with userInfo, and multiple
objects receive it, who, if anyone, is responsible for releasing it?
From what I understand, when you send a Notification with userInfo this
happens:
1) the userInfo dictionary itself retains the objects placed in it
2) the Notification retains the userInfo dictionary
what I do not understand is, if I send a notification and multiple
objects receive it... what happens memory-wise?
The object's I'd be placing in the userInfo are not needed by the
sending object after the notification is sent. So, I intend to
autorelease them. Since the userInfo Dictionary retains them, I feel
confident that the recipients of the notification will receive them
intact. However, I don't understand how long they will be valid.
Is the notification itself autoreleased? Does that mean that I have
everything in the
notification object only until my recipient method exits (or I retain
notification?)
Basically what I'm trying to determine is:
1) do I need to retain the object from the userInfo dictionary if I want
to keep it?
2) if I don't retain it, how long can I expect to have a valid object?
3) When do Notifications get released? Is it automatic?
Thanks for any help or pointers!
Jay
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.