Reputation: 9466
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.
Upvotes: 0
Views: 264
Reputation: 31645
First issue:
It should be:
snapshot.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
You should use init(scaleX:y:) CGAffineTransform initializer.
Swift 3 has many improvements on working with C APIs, you might want to check this proposal.
Second issue:
It should be:
let bool = indexPath == beginningIndexPath!
Note that IndexPath Struct is conforms to Equatable Protocol, ==
operator should works fine.
If you are using isEqual
then I assume that indexPath
was an instance of NSIndexPath; I recommend to check the NSIndexPath
class Documentation:
The Swift overlay to the Foundation framework provides the IndexPath structure, which bridges to the NSIndexPath class. The IndexPath value type offers the same functionality as the NSIndexPath reference type, and the two can be used interchangeably in Swift code that interacts with Objective-C APIs. This behavior is similar to how Swift bridges standard string, numeric, and collection types to their corresponding Foundation classes.
You can find what's the exact reason behind that by check Mutability and Foundation Value Types Proposal.
Upvotes: 0
Reputation: 404
First issue, use an initializer:
CGAffineTransform(scaleX: 1.05, y: 1.05)
Second issue, use the elementsEqual
:
let bool = indexPath!.elementsEqual(beginningIndexPath)
Upvotes: 3