5.7 Lecture - Pan Gestures for Dragging and Moving Labels


#1

Hi Paul or others,

I love the course you have set up and until now I could follow it pretty good… however, on day 5 you describe the word magnet application and I can’t get it to work… or even when I download the version you added I can’t even get that one to work. Is there something change in the swift code in mean time what broke your code? and if yes, could you please help me out how to fix it?

The code that is failing on me is:

var label = panGesture.view as UILabel

it give the error: UIView? is not convertible to UILabel; did you mean as! to force downcast?

I really hope someone can help me out with this cause I am stuck with the code right now?

Kind Regards,
Nico van der Linden


#2

Sorry I already found the problem, it seems you have to add an “!” in the code now:

var label = panGesture.view as! UILabel

might be a good thing to update the website Paul since more people might run into this? And I would like it if someone might be able to give an explanation of why this is necessary all of a sudden?

Thanks again for the great video’s, I really enjoy learning the programming :smiley: