2016-03-08 171 views
2

的Xcode 7和我的代碼的價值:無法將類型 '[RKDataStreamingMask]' 預期參數類型 'RKDataStreamingMask'

func sendSetDataStreamingCommand { 
let mask = RKDataStreamingMask.AccelerometerFilteredAll | 
RKDataStreamingMask.IMUAnglesFilteredAll | 
RKDataStreamingMask.QuaternionAll ; 
self.robot.enableSensors(mask,atStreamingRate:RKStreamingRate.DataStreamingRate10); 
} 

的警告是:

swift Binary operator '|' cannot be applied to two UIViewAutoresizing operands 

然後更改代碼:

func sendSetDataStreamingCommand { 
let mask=[RKDataStreamingMask.AccelerometerFilteredAll, 
RKDataStreamingMask.IMUAnglesFilteredAll, 
RKDataStreamingMask.QuaternionAll] 
self.robot.enableSensors(mask,atStreamingRate:RKStreamingRate.DataStreamingRate10); 
} 

then then warning in last sentence is:

Cannot convert value of type '[RKDataStreamingMask]' to expected argument type 'RKDataStreamingMask' 

請教我該怎麼辦?謝謝。

回答

1

要聲明一個包含OptionSetType的多個成員的變量,您必須顯式註釋該類型,否則方括號將被視爲一個數組。

let mask : RKDataStreamingMask = [.AccelerometerFilteredAll, .IMUAnglesFilteredAll, .QuaternionAll] 
+0

恩,謝謝你的幫助! ^^ – Yuri

相關問題