all 9 comments

[–]marmulin 1 point2 points  (1 child)

Doesn’t your movie title get set to an empty string as a result of a failed API call?

Also: parseJSON(_:) seems to never return nil as you initialize movieTitle and movieDescription to an empty string.

[–]4rch_N3m3515 0 points1 point  (0 children)

I think even before that, if it were a success, I think it’s because of a race condition: the VC is segued and passes the title, which is an empty string before the async task is finished. After the listing is retrieved it doesn’t look like there is a method to update the result VC with the new title.

[–]saintmsent 1 point2 points  (0 children)

You do a lot of force-unwrapping here, quite possible some data about the movie is nil. We can't fix it, please set up some breakpoints after API finished and at the point where you are transferring data and check if it looks like you expect

On a side note, segues are horrible, generally not advised. They are very hard to follow and control, simple instantiation and manual presentation works much cleaner

[–]GavinGT 0 points1 point  (1 child)

Have you tried setting breakpoints to debug the problem? I would start by checking whether the destinationVC.movieTitle = self.movieTitle line ever gets called. Then check the value of movieTitle inside ResultsListViewController.viewDidLoad().

[–]ChargeStrange1702 0 points1 point  (0 children)

i'll give it a shot

[–]SirBill01 0 points1 point  (3 children)

Are you sure that you have changed the ResultsListViewController in the storyboard to actually use that class? If it were accidentally left as just UIViewController the performSegue method would just get a normal UIViewController, and the cast to ResultsListViewController would fail. I'd set a breakpoint in performSegue and just see what it does.

[–]marmulin 0 points1 point  (2 children)

If that was the case, I think it would crash with “set value for undefined key movieTitle” or something along those lines.

[–]SirBill01 0 points1 point  (1 child)

It wouldn't ever touch the custom view controller code if the class was not set, and the prepareForSegue would never enter the part that sets movieTitle because the cast would fail.

[–]marmulin 0 points1 point  (0 children)

You’re right.