OGeek|极客世界-中国程序员成长平台

标题: ios - 如何在 Phonegap iOS 中传递 boolean 值 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:33
标题: ios - 如何在 Phonegap iOS 中传递 boolean 值

我的 JS 调用看起来像这样

cordova.exec(function () { }, function () { }, "rogressHUD", "show", [ _message, _messageLong, determined ]);

确定是真值还是假值

在我正在做的函数中

BOOL determined = [command argumentAtIndex:2];

if(determined) {
    // do thing
} else {
    // do other thing
}

不知道为什么这不起作用。如果我尝试使用 NSNumber*NSString* 而不是 BOOL,那么我的日志会给我 1 或 0 作为传入的值。

但我什至因为某种原因做不到

if(determined == 1) {

如果我这样做,代码甚至不会运行,或者就此引发语法错误。

有什么想法可以在这里检查 Objective C 中的 boolean 值吗?



Best Answer-推荐答案


答案是检查 boolean 值

if([determined boolValue] == YES) {

关于ios - 如何在 Phonegap iOS 中传递 boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25415236/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4