ios - Calling UIWebView from different class -


i have viewcontroller1.m , viewcontroller2.m

in viewcontroller1.m have uiwebview , created method load url.

if call method viewcontroller1.m works. when try call method viewcontroller2.m not work.

i realised because creating new instance of viewcontroller1.m class.

so question is, how can call method active instance of viewcontroller1 class?

best regards,

i able need using notifications. dont know if best way of doing worked me.

i hope useful else.

in viewcontroller1.m

- (void)viewdidload {  [[nsnotificationcenter defaultcenter] addobserver:self        selector:@selector(receivetestnotification:) name:@"testnotification" object:nil];  }  - (void) receivetestnotification:(nsnotification *) notification   {  [yourwebview stringbyevaluatingjavascriptfromstring:@"alert('it works');"];   } 

in viewcontroller2.m

-(void) somemethod { [[nsnotificationcenter defaultcenter]      postnotificationname:@"testnotification"      object:self];      [self dismissviewcontrolleranimated:yes completion:nil]; } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -