Xcode 7和我的代码:

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);
}

最后一句警告是:
Cannot convert value of type '[RKDataStreamingMask]' to expected argument type 'RKDataStreamingMask'

请教我怎么做?谢谢。

最佳答案

若要声明包含多个OptionSetType成员的变量,必须显式注释该类型,否则方括号将被视为数组。

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

09-27 02:17