ios - NSNotification register place issue -


i have tab bar application in there 2 tabs(2 view controllers). need post notification tab 2(view controller 2) tab 1(view controller 1). problem have first go tab 1(view controller 1) in order register notification, if dont notification never registered. seems view allocated once select , move tab 2(view controller 2) post notification.

in register notification in viewdidload , viewwillappear this:

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

so, how can avoid first selecting tab 1(view controller 1) , post notification tab 2(view controller 2)?

thanks!!

if have instances of view controllers in tabs in appdelegate try in applicationdidfinishlaunching

[[nsnotificationcenter defaultcenter] addobserver:tab1viewcontroller selector:@selector(createyourownpressed:) name:@"createyourownpressed" object:nil]; 

or this, while adding view controller uitabbarcontroller

viewcontroller *vc=[[viewcontroller alloc]initwithnibname:@"viewcontroller" bundle:nil]; [[nsnotificationcenter defaultcenter] addobserver:vc selector:@selector(createyourownpressed:) name:@"createyourownpressed" object:nil]; 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -