1

외부 기기와 블루투스 연결이 필요한 앱을 만들고 있는데 외부 기기와 성공적으로 연결되었습니다.CoreBluetooth : CBPeripheral에는 회원이 없습니다 setnotifyValue iOS 10.0

이제 CBPeripheralManager 위임 아래에있는 것은 아이폰 OS 10에서 오류를 생성 및 iOS에서 완벽하게 작동 9.0 그것은 CBPeripheral 더를 가지고 있다고 말한다

peripheral.setNotifyValue(true, forCharacteristic: characteristics[0]) 

나는 아래 줄에 오류가 발생하고

func peripheral(peripheral: CBPeripheral, didDiscoverCharacteristicsForService service: CBService, error: NSError?) { 

    if serviceCharacteristics.keys.contains(service.UUID) { 
     guard let characteristics = service.characteristics else { return } 

     peripheral.setNotifyValue(true, forCharacteristic: characteristics[0]) 

} 

, 멤버 setNotifyValue. 나는 그것을 얻지 않는다. 몇 가지 해결 방법을 시도했지만 도움이되지 않았습니다.

답변

2

스위프트 3을 사용하고 있습니까? setNotifyValue(_:for:)The method signature has changed는, 즉 :

peripheral.setNotifyValue(true, for: characteristics[0]) 
+0

Nice. 무승부에 더 빨리. ;) – davidethell

+1

당신은 우리의 답변이 얼마나 비슷한 지 보십니까? 우리는 똑같은 유선 두뇌가 있어야합니다. –

+0

이전에 배포 대상을 변경하고 위의 오류가 발생하는 응용 프로그램을 실행하려고하면 swift 2.3에서 코드를 작성했습니다. # 사용 가능한 (iOS 10.0, *) { 주변기기 .setNotifyValue (true의 경우 : 특성 [0]) } else { peripheral.setNotifyValue (enabled : true, characteristic : characteristics [0] ]) } –

0

당신은 빠른 3로 마이그레이션나요? 새 구문은 "forCharacteristic"대신 "for"를 사용합니다.

peripheral.setNotifyValue(true, for: characteristics[0])