在过去(Objective-C)我可以使用如下的browsedDeviceTypeMask属性:
mDeviceBrowser.browsedDeviceTypeMask = ICDeviceLocationTypeMaskLocal|ICDeviceLocationTypeMaskRemote|ICDeviceTypeMaskScanner
我将其转换为:
mDeviceBrowser.browsedDeviceTypeMask = ICDeviceLocationTypeMask.Local | ICDeviceLocationTypeMask.Shared | ICDeviceLocationTypeMask.Bluetooth | ICDeviceLocationTypeMask.Bonjour
但是我收到了错误消息:
Binary Operator '|' cannot be applied to tow 'ICDeviceLocationTypeMask' operands
有任何帮助来解决这个问题吗?
答案 0 :(得分:2)
这是Swift 2的语法:
mDeviceBrowser.browsedDeviceTypeMask = ICDeviceTypeMask(rawValue:
ICDeviceLocationTypeMask.Local.rawValue |
ICDeviceLocationTypeMask.Shared.rawValue |
ICDeviceLocationTypeMask.Bonjour.rawValue |
ICDeviceLocationTypeMask.Bluetooth.rawValue)!;