我是 iOS 和 Phonegap 的新手,所以请多多包涵。我的 index.html 中有以下代码 -
function onDeviceReady()
{
// do your thing!
//navigator.notification.alert("PhoneGap is working");
MyClass.nativeFunction(
["HelloWorld"] ,
function(result) {
alert("Success : \r\n"+result);
},
function(error) {
alert("Error : \r\n"+error);
}
);
}
我有另一个名为 MyClass.js 的文件,其中包含以下内容 -
var MyClass = {
nativeFunction: function(types, success, fail) {
return PhoneGap.exec(success, fail, "MyClass", "print", types);
}
}
我有一个名为 MyClass 的 Objective C 类,其方法 print 具有 NSLog 语句。但这永远达不到。这是什么原因?
更新:我的 .h 类
#import <Foundation/Foundation.h>
#import <PhoneGap/PGPlugin.h>
@interface MyClass : PGPlugin {
NSString* callbackID;
}
@property (nonatomic, copy) NSString* callbackID;
//Instance Method
- (void) print:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end