感谢你的建议;我最终通过 XCode 7 文档找到了答案。以下函数的 XCode 6 语法如下:
func centralManagerDidUpdateState(central: CBCentralManager!) {}
func centralManager(central: CBCentralManager!, didDiscoverPeripheral peripheral: CBPeripheral!, advertisementData advertisementData: [NSObject : AnyObject]!, RSSI RSSI: NSNumber) {}
func centralManager(central: CBCentralManager!, didConnectPeripheral peripheral: CBPeripheral!) {}
func centralManager(central: CBCentralManager!, didDisconnectPeripheral peripheral: CBPeripheral!, error: NSError!) {}
func peripheral(peripheral: CBPeripheral!, didDiscoverServices error: NSError!) {}
func peripheral(peripheral: CBPeripheral!, didDiscoverCharacteristicsForService service: CBService!, error: NSError!) {}
func peripheral(peripheral: CBPeripheral!, didUpdateNotificationStateForCharacteristic characteristic: CBCharacteristic!, error: NSError!) {}
func peripheral(peripheral: CBPeripheral!, didUpdateValueForCharacteristic characteristic: CBCharacteristic!, error: NSError!) {}
但是,这些函数将与 XCode 7 CoreBluetooth 库声明冲突。
注意不同用途选项也数据类型.
(XCode 6) error:NSError!
vs. (XCode 7) error:NSError?
(XCode 6) advertisementData : [NSObject : AnyObject]!
vs. (XCode 7) advertisementData [String : AnyObject]
XCode 7 beta 的相应函数声明实际上如下:
func centralManagerDidUpdateState(central: CBCentralManager) {}
func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {}
func centralManager(central: CBCentralManager, didConnectPeripheral peripheral: CBPeripheral) {}
func centralManager(central: CBCentralManager, didFailToConnectPeripheral peripheral: CBPeripheral, error: NSError?) {}
func peripheral(peripheral: CBPeripheral, didDiscoverServices error: NSError?) {}
func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) {}
func peripheral(peripheral: CBPeripheral, didUpdateValueForCharacteristic characteristic: CBCharacteristic, error: NSError?) {}
func peripheral(peripheral: CBPeripheral, didUpdateNotificationStateForCharacteristic characteristic: CBCharacteristic, error: NSError?) {}
func centralManager(central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: NSError?) {}
希望这对遇到同样问题的其他人有帮助!