获取IAP产品响应后的Objective-C错误 [英] Objective-C errors after getting the IAP product response

查看:134
本文介绍了获取IAP产品响应后的Objective-C错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码来自Phonegap代码:IAP插件。错误发生在发送js之后的代码行。发送到函数的所有元素都是非零,除了最后一个nil。我甚至登出他们,以确保他们发送。此代码即将使用此插件( https://github.com/usmart/InAppPurchaseManager-EXAMPLE)并且除了日志记录之外没有被修改。在调试器中我看到没有对象是nil,所以我不明白为什么错误正在发生。

This code is from the Phonegap Code: IAP Plugin. The error happens on the line of the code right after the "sent js". All the elements sent to the function are non-nil except for the last one 'nil'. I even logged them out to make sure they were sent. This code is right out of the plugin (https://github.com/usmart/InAppPurchaseManager-EXAMPLE) and has not been modified except for the logging. In the debugger i saw that none of the objects were nil, so i don't understand why the error is happening.

这里是错误:


[__ NSArrayI JSONRepresentation]:无法识别的选择器发送到
实例0xdc542d0
2013-02-13 23:26:17.209 GoblinSlots [4519: 707] 由于未捕获异常NSInvalidArgumentException而终止应用程序,原因:
' - [__ NSArrayI JSONRepresentation]:无法识别的选择器发送到
实例0xdc542d0'

[__NSArrayI JSONRepresentation]: unrecognized selector sent to instance 0xdc542d0 2013-02-13 23:26:17.209 GoblinSlots[4519:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI JSONRepresentation]: unrecognized selector sent to instance 0xdc542d0'

这里是代码:

      - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:   (SKProductsResponse *)response
      {
        NSLog(@"got iap product response");
        for (SKProduct *product in response.products) {
            NSLog(@"sending js for %@", product.productIdentifier);
            NSLog(@"  title %@", product.localizedTitle );
            NSLog(@"  desc%@ - %@", product.localizedDescription, product.localizedPrice );


NSArray *callbackArgs = [NSArray arrayWithObjects:
                                 NILABLE(product.productIdentifier),
                                 NILABLE(product.localizedTitle),
                                 NILABLE(product.localizedDescription),
                                 NILABLE(product.localizedPrice),
                                 nil ];
        NSLog(@"sent js");

        NSString *js = [NSString stringWithFormat:@"%@.apply(plugins.inAppPurchaseManager, %@)", successCallback, [callbackArgs JSONSerialize]];
        NSLog(@"js: %@", js);
        [command writeJavascript: js];
    }


推荐答案

JSONRepresentation SBJson 添加的类别,因此您必须将 SBJson.h 使用它的类。

JSONRepresentation is a category that SBJson adds so you have to include SBJson.h in the class that uses it.

这篇关于获取IAP产品响应后的Objective-C错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆