Operation mapping देखें
Device operations और उन्हें assigned device functions की mapping पढ़ें।
आवश्यक शर्तें
- Device connected और ready हो
- Device
DevicePhysicalOperationsAPIsupport करता हो
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>Protocol की घोषणा
Mapping DevicePhysicalOperationsAPI की property के रूप में expose होती है।
- 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उपलब्ध properties
| Property | Type | विवरण |
|---|---|---|
physicalOperationsMapping | [NSNumber: NSNumber]? | हर DeviceOperation raw value को DeviceFunction raw value से map करता है। |
Return value
यह read-only optional property है, asynchronous query method नहीं।
उपयोग के उदाहरण
- 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);
}];Error handling
Property में completion handler नहीं है। Unsupported protocol conformance, nil mapping और known enum case में initialize न होने वाले raw values संभालें।
बेहतर तरीके
- Values को enum raw values मानें: Keys और values को
DeviceOperationऔरDeviceFunctionसे convert करें। - Missing entries का अनुमान न लगाएँ: जो operation नहीं मिला, उसे supported न मानें।
- Assignment के बाद UI refresh करें: Device mapping update करता हो तो सफल assignment के बाद property दोबारा पढ़ें।
ध्यान देने योग्य बातें
- SDK Demo इस property को सीधे पढ़ता है और display के लिए entries को operation raw value से sort करता है।
- Property
Resultcallback याKeyMappingmodel उपयोग नहीं करती।