Re: Where is it better to register with NSNotificationCenter in class?
Re: Where is it better to register with NSNotificationCenter in class?
- Subject: Re: Where is it better to register with NSNotificationCenter in class?
- From: Dave Hersey <email@hidden>
- Date: Tue, 25 Mar 2008 01:31:19 -0400
The other thing I should have mentioned is that when you add items to
an array, they are retained, so you don't need to retain each of the
strings. I think the problem is probably your missing nil in the
object list. The array contents are probably hosed.
It's reasonable to retain the array in this case as you're doing.
Otherwise it will be autoreleased.
- d
On Mar 25, 2008, at 1:21 AM, Dave Hersey wrote:
The list for arrayWithObjects needs to end with a nil object.
- d
On Mar 25, 2008, at 1:16 AM, Samvel wrote:
Reason: I thought that at some point NSNotificationCenter has to be
instantiated in an application loading process and my constructor
may have executed at earlier stage.
Answer: Unfortunately the reason was much simpler than that. It
turned out to be an example (answer) to my prev. question regarding
memory management. At some point later in my constructor an array
is supposed to be created. Basically it has to be a collection of
string and I did it this way:
dimensions = [NSArray arrayWithObjects: @"1920x1440",
@"1600x1200",
@"1280x1024",
@"1024x768"];
[dimensions retain];
So, strings are not actually retained. :( and this led to odd
behavior.
Samvel.
_______________________________________________
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