Ios 缺少'';swizzle方法Swift 3迁移后的分隔符
我无法将下面的代码转换为Swift 3语法:Ios 缺少'';swizzle方法Swift 3迁移后的分隔符,ios,swift,swift3,Ios,Swift,Swift3,我无法将下面的代码转换为Swift 3语法: extension UIView { override public static func initialize() { if !didEAInitialize { replaceAnimationMethods() didEAInitialize = true } } private static func replaceAnimatio
extension UIView {
override public static func initialize() {
if !didEAInitialize {
replaceAnimationMethods()
didEAInitialize = true
}
}
private static func replaceAnimationMethods() {
//replace actionForLayer...
method_exchangeImplementations(
class_getInstanceMethod(self, #selector(UIView.actionForLayer(_:forKey:))),
class_getInstanceMethod(self, #selector(UIView.EA_actionForLayer(_:forKey:))))
//replace animateWithDuration...
method_exchangeImplementations(
class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:)(_:animations:))),
class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:animations:))))
method_exchangeImplementations(
class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:completion:)(_:animations:completion:))),
class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:animations:completion:))))
method_exchangeImplementations(
class_getClassMethod(self, #selector(UIView.animate(withDuration:delay:options:animations:completion:)(_:delay:options:animations:completion:))),
class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:delay:options:animations:completion:))))
method_exchangeImplementations(
class_getClassMethod(self, #selector(UIView.animate(withDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)(_:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:))),
class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:))))
}
}
上面的代码是在运行迁移工具之后编写的。例如,我最初有:
method_exchangeImplementations(
class_getClassMethod(self, #selector(UIView.animateWithDuration(_:animations:))),
class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:animations:))))
但是现在在第二行,我得到了
class\u getClassMethod(self,#selector(UIView.animate)(withDuration:animations:)的错误Expected',separator
。我做错了什么?迁移工具并不总是完美的。只需使第一行看起来像第二行,但不带EA\uu
前缀。改变
class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:)(_:animations:))),
到
以此类推……这样做了,错误消失了,但现在每第二行都有预期的“,”分隔符
error@matt我想你需要在,
之前再加上一个括号!谢谢@萨姆,锐利的眼睛!谢谢
class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:))),