swift UIDynamicAnimator crash

286 Views Asked by At

Iam trying to to add a view to UIGravityBehavior (which I created graphicall by cmd+drag it to my code and creating an Outlet) but my app crashes , although when I create the same view in code and add it to my UIGravityBehavior it works perfectly ! ?? I am working with the new Swift language and this is my simple code

animator = UIDynamicAnimator(referenceView: view)
gravity = UIGravityBehavior(items: [welcomeView])
animator.addBehavior(gravity)

welcomeView is an Outlet : @IBOutlet weak var frontView: UIView!

whats the problem ??? thx

1

There are 1 best solutions below

4
On

Most likely one of your IBOutlets is nil because you didn't attach it. When you then try to access it, it'll crash. Make sure you've actually made all your connections in IB.

If your IBOutlet is linked it'll have a little filled-in circle beside it.

Unlinked IBOutlet: Unlinked IBOutlet

Linked IBOutlet: Linked IBOutlet