在 Objective-C 中使用两个参数调用 void 函数
Invoking void function with two arguments in Objective-C
我正在编写自定义 Cordova 插件来调用 Guided Access mode of iOS using UIAccessibilityRequestGuidedAccessSession,我在 cordova-ios-guided-access.m
中编写了以下代码:
#import <Cordova/CDV.h>
@interface WPGuidedAccessMode : CDVPlugin {
// Member variables go here.
}
- (void)start:(CDVInvokedUrlCommand*)command;
@end
@implementation WPGuidedAccessMode
- (void)start:(CDVInvokedUrlCommand*)command {
BOOL enableFoo = true;
UIAccessibilityRequestGuidedAccessSession(enableFoo completion:^(BOOL didSucceed) {
NSLog(@"Animation over..");
NSLog(didSucceed ? @"Yes" : @"No");
});
}
@end
但是当我运行这段代码时,我收到以下错误:
我也尝试了其他几种语法,并通过各种 SO 链接来调用函数,但没有任何效果。我错过了什么?
您在 enableFoo
之后缺少 ,
,需要删除 completion:
应该是
UIAccessibilityRequestGuidedAccessSession(enableFoo, ^(BOOL didSucceed) {
NSLog(@"Animation over..");
NSLog(didSucceed ? @"Yes" : @"No");
});
我正在编写自定义 Cordova 插件来调用 Guided Access mode of iOS using UIAccessibilityRequestGuidedAccessSession,我在 cordova-ios-guided-access.m
中编写了以下代码:
#import <Cordova/CDV.h>
@interface WPGuidedAccessMode : CDVPlugin {
// Member variables go here.
}
- (void)start:(CDVInvokedUrlCommand*)command;
@end
@implementation WPGuidedAccessMode
- (void)start:(CDVInvokedUrlCommand*)command {
BOOL enableFoo = true;
UIAccessibilityRequestGuidedAccessSession(enableFoo completion:^(BOOL didSucceed) {
NSLog(@"Animation over..");
NSLog(didSucceed ? @"Yes" : @"No");
});
}
@end
但是当我运行这段代码时,我收到以下错误:
我也尝试了其他几种语法,并通过各种 SO 链接来调用函数,但没有任何效果。我错过了什么?
您在 enableFoo
之后缺少 ,
,需要删除 completion:
应该是
UIAccessibilityRequestGuidedAccessSession(enableFoo, ^(BOOL didSucceed) {
NSLog(@"Animation over..");
NSLog(didSucceed ? @"Yes" : @"No");
});