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: "Sherm Pendley" <email@hidden>
- Date: Tue, 25 Mar 2008 01:06:39 -0400
On Tue, Mar 25, 2008 at 12:51 AM, Samvel <email@hidden> wrote:
> Hi,
>
> I run into troubles trying to register my object with
> NSNotificationCenter in class
> -(id) init;
>
> Basically here is my constructor:
> -(id) init
> {
> self = [super init];
>
> if( self) {
> [[NSNotificationCenter defaultCenter]
> addObserver: self
> selector : @selector( downloadStarted:)
> name : @"DownloadStarted"
> object : nil];
> //... (at this point self has lost it's original value having
> some '<value')
What leads you to believe that is the case?
}
>
> return self;
> }
>
> So, what method is the best place to put registration with
> NSNotificationCenter to?
What method is the best place to use a for() loop? Seriously - the answer is
the same, you put it wherever makes the most sense in your app.
What kind of problem led to this question? No offense intended, but I'm
honestly having trouble figuring out just what it is that you're asking
here. Adding self as an observer object doesn't change the value of self,
and there are no special requirements about the "best place" to register for
notifications.
> Ultimately I wish it would be done on
> automatic basis in similar way as with:
> -(id) init;
There's no reason an object can't or shouldn't register itself for
notifications. Again - what makes you think it would cause problems?
sherm--
_______________________________________________
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