objective c - Selector don't getting notification from NSNotificationCenter (iOS) -


i sending notification class inherits nsobject using nsnotificationcenter.

the notification should sent 2 viewcontroller it's being sent 1 of them.

my code:

fetchfromparse:

-(void)sendallstores {     [[nsnotificationcenter defaultcenter]postnotificationname:@"getstoresarrays" object:nil userinfo:self.storesdict]; } 

firstvc.m (working):

- (void)viewdidload {     [[nsnotificationcenter defaultcenter]addobserver:self selector:@selector(getstoresarrays:) name:@"getstoresarrays" object:nil]; }  -(void)getstoresarrays:(nsnotification*)notification {     nslog(@“working”); //working    } 

secondvc.m (not working):

-(void)preparearrays {     [[nsnotificationcenter defaultcenter]addobserver:self selector:@selector(getstoresarrays:) name:@"getstoresarrays" object:nil]; } -(void)getstoresarrays:(nsnotification*)notification {     nslog(@“not working”); //not working } 

appdelegate.m:

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     secondvc *secvc=[[secondvc alloc] init];     [secvc preparearrays];      fetchfromparse *fetchfromparseobj=[[fetchfromparse alloc] init];     [fetchfromparseobj getstoresfromparse];      return yes; } 

note: xcode shows me error message "firstvc not registered observer".

the logic code not correct. posting notification , have made 2 classes observer, lead unpredictable results. should have 1 class observer notification.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -