İşlem Eşlemesini Görüntüleme
Fiziksel cihaz işlemleri ile atanmış cihaz işlevleri arasındaki eşlemeyi okuyun.
Ön Koşullar
- Cihaz bağlı ve hazırdır
- Cihaz
DevicePhysicalOperationsAPIprotokolünü destekler
API Referansı
Framework
AIBuds.xcframework
İçe Aktarma
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protokol
Eşleme, DevicePhysicalOperationsAPI protokolünün bir özelliği olarak sunulur.
- Swift
- Objective-C
/// 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 }
}/// The protocol for device physical operations API.
@protocol AIBudsDevicePhysicalOperationsAPI <AIBudsDeviceAPI>
/// 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``.
@property(nonatomic, readonly, copy)
NSDictionary<NSNumber *, NSNumber *> *_Nullable physicalOperationsMapping;
@endÖzellikler
| Özellik | Tür | Açıklama |
|---|---|---|
physicalOperationsMapping | [NSNumber: NSNumber]? | Her DeviceOperation raw değerini bir DeviceFunction raw değeriyle eşler. |
Dönüş Değeri
Bu, eşzamansız sorgu yöntemi değil; isteğe bağlı ve salt okunur bir özelliktir.
Kullanım Örnekleri
- Swift
- Objective-C
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))")
}#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
id<AIBudsDevicePhysicalOperationsAPI> device = (id<AIBudsDevicePhysicalOperationsAPI>)self.device;
if (![device conformsToProtocol:@protocol(AIBudsDevicePhysicalOperationsAPI)]) {
NSLog(@"Device does not support physical-operation mapping");
return;
}
[device.physicalOperationsMapping
enumerateKeysAndObjectsUsingBlock:^(NSNumber *operation, NSNumber *function, BOOL *stop) {
NSLog(@"Operation %@ → function %@", operation, function);
}];Hata Yönetimi
Özelliğin completion handler'ı yoktur. Desteklenmeyen protokolü, nil eşlemeyi ve bilinen enum case'lerine dönüşmeyen raw değerleri işleyin.
En İyi Uygulamalar
- Değerleri Enum Raw Değerleri Olarak İşleyin: Anahtarları ve değerleri
DeviceOperationveDeviceFunctionüzerinden dönüştürün. - Eksik Kayıtları Varsaymayın: Eşlemede bulunmayan bir işlem destekleniyor sayılmaz.
- Atamadan Sonra Arayüzü Yenileyin: Cihaz özelliği güncelliyorsa başarılı atamadan sonra yeniden okuyun.
Notlar
- SDK Demo'su bu özelliği doğrudan okur ve gösterim için kayıtları işlem raw değerine göre sıralar.
- Özellik bir
Resultcallback'i veyaKeyMappingmodeli kullanmaz.