icekomo icekomo -4 years ago 183
Swift Question

Converting from Swift 2 to Swift 3 errors

Im working my way through this tutorial on using a gesture on a tableview cell with CoreData.

I got most of it converted by there are 2 places where I have ran into an issue.

1.

Swift2:

snapshot.transform = CGAffineTransformMakeScale(1.05, 1.05);


Swift 3:

snapshot.transform = CGAffineTransform.scaledBy(1.05, 1.05)


This is the error I'm getting:

Use of instance member 'scaledBy' on type 'CGAffineTransform'; did you mean to use a value of type 'CGAffineTransform' instead?





Here is the 2nd issue.

Swift 2:

let bool:Bool = indexPath!.isEqual(beginningIndexPath) as Bool


Swift 3:

let bool:Bool = indexPath!.isEqual(beginningIndexPath) as Bool


error:

Value of type 'IndexPath' has no member 'isEqual'


I tried to use the == as a replacement, but that didn't work either.

Answer Source

First issue, use an initializer:

CGAffineTransform(scaleX: 1.05, y: 1.05)

Second issue, use the elementsEqual:

let bool = indexPath!.elementsEqual(beginningIndexPath)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download