ios - Passing string to separate WebViewController doesn't take -


i new objective c , xcode, have come long way in learning following tutorials , searching on stack overflow. have encountered problem can’t seem find solution for. know must doing wrong (perhaps storyboard set incorrectly). attempting load embedded webpage in second scene pressing button in first scene. need button press pass nsstring containing url address. have tried various senders - 1 using is:

- (ibaction)websitebuttonpressed:(id)sender {      webviewcontroller *destinationcontroller = [[webviewcontroller alloc]         initwithstring:self.webinfo];     destinationcontroller.webinfo = _webinfo;  } 

the _webinfo nsstring containing url.

the webviewcontroller .h file defines initwithstring follows:

- (id)initwithstring:(nsstring *)webinfo; 

and webviewcontroller .m file contains following code:

@synthesize weburl;    - (id)initwithstring:(nsstring *)webinfo {    self = [super initwithnibname:@"webviewcontroller" bundle:nil];    if (self) {     weburl = [webinfo copy];            }    return self; } 

inserting breakpoint here indicates appropriate url string being passed webviewcontroller. when following viewdidload code executed, weburl , webview empty, though weburl had appropriate nsstring in init.

 nsurl *requesturl = [nsurl urlwithstring:weburl];    nsurlrequest *request = [nsurlrequest requestwithurl:requesturl]; [self.webview loadrequest:request]; 

does have ideas doing wrong? totally baffled problem. have tried number of different approaches same result. if insert nsurl *requesturl = [nsurl urlwithstring:@"http://www.apple.com"]; in viewdidload, apple site displayed properly.

the quick , easy solution move code viewdidload initwithstring

or

create setter methods property webinfo , write code load webview url there.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -