Errata for iOS Animations by Tutorials, 6th Edition

Found an issue in iOS Animations by Tutorials, 6th edition? Post it here!

Error out of the box.

Line 88 of ViewController.swift:
let imageView = listView.viewWithTag(i) as! UIImageView
Could not cast value of type ‘UIView’ (0x7fff895ce1e8) to ‘UIImageView’ (0x7fff895cde00).

Same error as this guy.

Hello, I’ll ask you the same question as I asked the other person:

Please can I check that you’re using the latest edition of the book and materials (6)? I’ve just now downloaded the materials for the latest edition, I’m running this project absolutely fine in Xcode 11.1 GM, and it’s chapter 19 now, not 17.

Thanks

Rich

Ah! I was using edition 5. I’m signed up for the newsletter, but I must’ve missed the update. Thanks! I guess I have to start over using SwiftUI.

There are two new SwiftUI chapters, but the rest of the book is still as it was before.

The crash is down to differences in the internals of scroll views in the new version of iOS, so there are more subviews. The code wants there to be only one subview with a tag of zero, but that’s the default tag value, so it’s setting all the other subviews to a tag of 1000. The updated code keeps doing this until there are no views with tag 0 tags before building the list, the previous code only did it for the first subview.

This topic was automatically closed after 166 days. New replies are no longer allowed.