2017-08-30 72 views
2

請看看這個簡單的銀行代碼:什麼是Objective-C相當於一個空的Swift OptionSet?

UIView.animate(withDuration: duration, delay: interButtonDelay * Double(expanding ? index : index + 1), options: [], animations: { 
      button.transform = expanding ? .init(scaleX: self.scale, y: self.scale) : .identity 
      button.alpha = expanding ? 0.0 : 1.0 
     }, completion: nil) 

這裏一個空數組傳遞到options參數。我想找出什麼是正確的Objective-C相當於這樣做。我認爲它應該通過0,但我想完全確定。不幸的是,文件沒有告訴任何有關這一點。

+0

Ç枚舉是整數,所以0是一個有效的值通過 – Mindaugas

回答

7

斯威夫特的OptionSet被創建使掩碼更愉快使用。在Swift中,你將合併後的價值拼湊成一個集合;在Objective-C,這是一個整數值,用位運算符建:

NSUInteger options = UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseOut; 

Objective-C的等效於一個空OptionSet因此確實只是0