我的 JS 调用看起来像这样
cordova.exec(function () { }, function () { }, "ProgressHUD", "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 值有什么想法吗?
最佳答案
答案是检查 boolean 值本身
if([determined boolValue] == YES) {
关于ios - 如何在 Phonegap iOS 中传递 boolean 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25415236/