uchicago-mobi / 2015-Winter-Forum

8 stars 1 forks source link

Problem with delegate method #132

Closed mattmeier closed 9 years ago

mattmeier commented 9 years ago

Sorry, if this is a stupid question, but I have struggled for hours with this... Basically I've got a delegate method, which gets triggered from the MasterViewController to the DetailViewController whenever a table cell is clicked on and then sends along the NSURL of the given article. This works all fine, i.e. I properly receive the URL in my DetailViewController (which I can see in an NSLog). However, when I convert the NSURL into an NSURLRequest (still NSLogable) and try to load my web view with this request by [self.webView loadRequest:request] nothing happens (and the webView is definitely properly set up, since I can call it from e.g. viewDidLoad). I have also tried to just set a strong property currentRequest with the given NSURL through calling another method I created - (void)setRequest:(NSURL*)requestURL, which, however, gets null when I call it from the delegate method, but not null, when I call the setRequest method from e.g. viewDidLoad. So basically all actions such as calling [self.webView loadRequest:request] or setting strong properties by calling separate methods such as my setRequest seem to get overridden/nullified by memory management or so? Anyone has an idea on what my error could be??

johnnypaper commented 9 years ago

Have you connected the outlet in storyboard or set the class so that the webView recognizes it?

If not if you can retrieve the link, then set that to a string and then NSURL and then NSRULRequest then self.webView loadRequest ....you should be good then.

I think it would more than likely be that you haven't told the request where it should be going (to what webView). Otherwise if you are programmatically writing everything then it should be [self.view addSubview:self.webView]

mattmeier commented 9 years ago

Yep, I connected the outlet in storyboard, and it works when I e.g. call self.webView loadRequest with a random URL from viewDidLoad...

johnnypaper commented 9 years ago

So then there is a disconnect between the segue from masterViewController and the DetailViewController... what are you passing through there? Are you passing the setDetailItem a dictionary Item where you can retrieve the link in the DetailVC?

My next guess is something isn't getting properly passed there...although you say that you are able to call whatever you are passing in the setDetailItem in the DetailVC?

mattmeier commented 9 years ago

Thanks a lot, the approach with the Segue actually did the job (although I still don't understand, why everything being called/set from my delegate method gets null)!

johnnypaper commented 9 years ago

No problem...glad you got it fixed.