2

在过去(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

有什么帮助解决这个问题吗?

4

1 回答 1

2

这是 Swift 2 的语法:

mDeviceBrowser.browsedDeviceTypeMask = ICDeviceTypeMask(rawValue:
   ICDeviceLocationTypeMask.Local.rawValue |
   ICDeviceLocationTypeMask.Shared.rawValue |
   ICDeviceLocationTypeMask.Bonjour.rawValue |
   ICDeviceLocationTypeMask.Bluetooth.rawValue)!;
于 2015-10-20T17:16:33.260 回答