ios - 从 Swift 2 转换为 Swift 3 错误

标签 ios swift xcode swift3

我正在努力通过 this有关在带有 CoreData 的表格 View 单元格上使用手势的教程。

我在 2 个地方遇到了问题,因此大部分内容都已转换。

1.

Swift2:

snapshot.transform = CGAffineTransformMakeScale(1.05, 1.05);

swift 3:

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

这是我遇到的错误:

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

这是第 2 期。

swift 2:

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

swift 3:

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

错误:

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

我尝试使用 == 作为替代,但这也不起作用。

最佳答案

第一期,使用初始化器:

CGAffineTransform(scaleX: 1.05, y: 1.05)

第二期,使用elementsEqual:

let bool = indexPath!.elementsEqual(beginningIndexPath)

关于ios - 从 Swift 2 转换为 Swift 3 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42958421/

相关文章:

ios - 如何将字符串(例如 "xPM - yPM")拆分为两个字符串,Swift

swift - 我想循环遍历集群注释中的所有注释

ios - 检测 UIImageView 与任何对象的碰撞

c++ - Xcode:使用 32 位库编译 64 位应用程序

ios - NSTask 或等效的 iPhone

ios - NSArrayWithObject :nil asserts, 但 NSArrayWithObjects :nil doesn't. 错误或功能?

ios - 创建 iOS/OS X 跨平台类

ios - 为什么在使用 initWithNibName 时需要 setNeedsDisplay

ios - 我的 Swift 获取请求返回具有错误关系的对象

objective-c - 使用 Xcode 生成 UML 代码