본문으로 건너뛰기

조작 매핑 조회

기기 조작과 할당된 기기 기능 사이의 매핑을 읽습니다.

사전 요구 사항

  • 기기가 연결되어 사용할 수 있는 상태입니다.
  • 기기가 DevicePhysicalOperationsAPI를 지원합니다.

API 참고

프레임워크

AIBuds.xcframework

가져오기

Swift
import AIBuds

프로토콜

매핑은 DevicePhysicalOperationsAPI의 속성으로 제공됩니다.

Swift
/// The protocol for device physical operations API.
protocol DevicePhysicalOperationsAPI: DeviceAPI {
    /// Physical operations with functions mapping
    /// - Returns: A dictionary mapping physical operation identifiers to function identifiers.
    ///
    /// The dictionary is structured as follows:
    /// - Keys: Physical operation identifiers. Defined in ``DeviceOperation``.
    /// - Values: Function identifiers. Defined in ``DeviceFunction``.
    var physicalOperationsMapping: [NSNumber: NSNumber]? { get }
}

속성

속성타입설명
physicalOperationsMapping[NSNumber: NSNumber]?DeviceOperation raw value를 DeviceFunction raw value에 매핑합니다.

반환 값

비동기 조회 메서드가 아니라 선택적 읽기 전용 속성입니다.

사용 예제

Swift
import AIBuds

guard let device = device as? DevicePhysicalOperationsAPI else {
    print("Device does not support physical-operation mapping")
    return
}

guard let mapping = device.physicalOperationsMapping else {
    print("Mapping is unavailable")
    return
}

for (operationValue, functionValue) in mapping {
    let operation = DeviceOperation(rawValue: operationValue.intValue)
    let function = DeviceFunction(rawValue: functionValue.intValue)
    print("\(String(describing: operation)) → \(String(describing: function))")
}

오류 처리

이 속성에는 completion handler가 없습니다. 프로토콜 미지원, nil 매핑 및 알려진 enum case로 변환할 수 없는 raw value를 처리하세요.

권장 사항

  1. enum raw value로 처리: 키와 값을 DeviceOperationDeviceFunction으로 변환하세요.
  2. 누락된 항목 추정 금지: 매핑에 없는 조작은 지원되는 것으로 정의되지 않습니다.
  3. 할당 후 UI 갱신: 기기가 매핑을 갱신하는 경우 할당 성공 후 속성을 다시 읽으세요.

참고

  • SDK Demo는 이 속성을 직접 읽고 표시할 때 조작 raw value 순으로 정렬합니다.
  • 이 속성은 Result 콜백이나 KeyMapping 모델을 사용하지 않습니다.