2016-09-21 105 views
0

我有問題與代碼塊:預計表達錯誤雨燕3.0

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.animateWithDuration(_:animations:))), 
      class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:animations:)))) 
     method_exchangeImplementations(
      class_getClassMethod(self, #selector(UIView.animateWithDuration(_:animations:completion:))), 
      class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:animations:completion:)))) 
     method_exchangeImplementations(
      class_getClassMethod(self, #selector(UIView.animateWithDuration(_:delay:options:animations:completion:))), 
      class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:delay:options:animations:completion:)))) 
     method_exchangeImplementations(
      class_getClassMethod(self, #selector(UIView.animateWithDuration(_:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:))), 
      class_getClassMethod(self, #selector(UIView.EA_animateWithDuration(_:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)))) 

    } 

我想遷移到雨燕3.0。

爲:

class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:)(_:animations:))), 

我收到錯誤Expected expression in list of expressions

爲:

class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:completion:)(_:animations:completion:))), 

我陷入了想法如何解決這個錯誤Expected ',' separator

。任何指針將非常感激。

回答

0

你有沒有試過像下面的語法。

class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:))) 
class_getClassMethod(self, #selector(UIView.animate(withDuration:animations:completion:)))