iphone - nsnotification trouble -


so have method:

-(void)didloginwithaccount(myaccount *)account 

and added observer method

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(didloginwithaccount:)]; 

and question is, when post notification, how can pass myaccount object?

when notification callback, notification object passed, , not object explicitly.

step 1, register:

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(didloginwithaccount:) name:@"mycustomnotification" object:nil]; 

step 2, post:

[[nsnotificationcenter defaultcenter] postnotificationname:@"mycustomnotification" object:myaccount];  

step 3, recieve:

- (void)didloginwithaccount:(nsnotification *)notification {     myaccount *myaccount = (myaccount *)[notification object]; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -