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
Post a Comment