我完全是菜鸟Objective-C
,我在从NSMutableArray
包含NSStrings
.
我正在制作一个iOS PhoneGap
需要使用剪贴板的项目。从我的javascript调用中破解了一个旧的iOS phonegap剪贴板插件:
cordova.exec(successFunction, failureFunction, "ClipboardPlugin", "setText", ["This is what it should be"]);
在哪里:
successFunction
=成功回调,
failureFunction
=失败回调,
" ClipboardPlugin
" = 拥有本机插件代码的类的名称
" setText
" = 调用设置剪贴板文本的类方法的名称,
[“这就是它应该是的”] = 参数数组的单个条目,它被传递给Clipboard.setText
方法。
当setText
方法被调用并且我在调试器中单步执行它时,它被正确调用并且正确的参数在数组中(即一个对象,value="This is what it should be"),但是当我尝试使用 访问它objectAtIndex:0
,它会返回一些意想不到的东西。
代码:
@implementation ClipboardPlugin
-(void)setText:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options{
/* At this point: NSMutableArray* arguments = 2 objects:
[0] 0x432432f0 @"This is what it should be"
[1] 0x00000000
- so far... so good!
*/
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *text = [arguments objectAtIndex:0];
[pasteboard setValue:text forPasteboardType:@"public.text"];
/* At this point:
NSString* text = ??? "What it should be" - ?? WRONG!
text = "@ClipboardPlugin1212332348"
*/
}
有什么想法吗?