某些需要傳參的函數(shù)需要將枚舉值轉(zhuǎn)化為對象,這個時候需要將枚舉值轉(zhuǎn)為原始值(對象),但是在收到參數(shù)的時候要根據(jù)枚舉值來操作,就需要將參數(shù)的原始值轉(zhuǎn)為枚舉值。舉例說明:
enum CheckType:NSNumber{
? case DirectSellers = 0, Marki, Maintenance, Recycling
}
1.獲取原始值rawValue
performSegueWithIdentifier("CheckDirectSellersViewController", sender: tmp.rawValue)
2.還原為枚舉值EnumName(rawValue: _)
viewController.ir_type=CheckType(rawValue: sender as! NSNumber)!