3

我正在尝试使用商店套件接收产品列表,但我不断收到异常:

未捕获的异常:NSInvalidArgumentException: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: 尝试从对象中插入 nil 对象[4]

这是来自控制台的堆栈跟踪:

0   CoreFoundation                      0x2fa12feb <redacted> + 154
    1   libobjc.A.dylib                     0x3a1bfccf objc_exception_throw + 38
    2   CoreFoundation                      0x2f9514a3 <redacted> + 530
    3   CoreFoundation                      0x2f95126b <redacted> + 50
    4   ninjaworld                          0x016d09d4 +[StoreKitSerializationHelpers jsonStringFromProductArray:] + 1312
    5   ninjaworld                          0x016ceaf4 -[StoreKitManager productsRequest:didReceiveResponse:] + 532
    6   StoreKit                            0x321c4863 <redacted> + 466
    7   libdispatch.dylib                   0x3a6a7833 <redacted> + 10
    8   libdispatch.dylib                   0x3a6a781f <redacted> + 22
    9   libdispatch.dylib                   0x3a6a7777 <redacted> + 254
    10  CoreFoundation                      0x2f9dd8f1 <redacted> + 8
    11  CoreFoundation                      0x2f9dc1c5 <redacted> + 1300
    12  CoreFoundation                      0x2f946f4f CFRunLoopRunSpecific + 522
    13  CoreFoundation                      0x2f946d33 CFRunLoopRunInMode + 106
    14  GraphicsServices                    0x3484b663 GSEventRunModal + 138
    15  UIKit                               0x3229216d UIApplicationMain + 1136
    16  ninjaworld                          0x000dcb5c main + 288
    17  ninjaworld                          0x000dca38 start + 40

此异常发生在调用任何回调方法之前。

如果我使用本机 iOS 代码,产品列表将成功检索。插件可能有问题。请指导我如何调试此代码,因为 Prime31 不会公开他们的代码。

我为插件启用了日志。产品列表检索成功。在那之后的某处引发异常。

日志:

-[StoreKitManager requestProductData:]
2014-09-01 07:42:00.702 ninjaworld[2519:60b] SKProductsRequest sent with productIdentifiers: {(
    "com.company.coinpack1",
    "com.company.coinpack4",
    "com.company.coinpack3",
    "com.company.coinpack2",
    "com.company.coinpack5"
)}
2014-09-01 07:42:07.654 ninjaworld[2519:60b] -[StoreKitManager productsRequest:didReceiveResponse:]
2014-09-01 07:42:07.658 ninjaworld[2519:60b] response.products.count: 5
2014-09-01 07:42:07.661 ninjaworld[2519:60b] response.products: (
    "<SKProduct: 0x16df4ca0>",
    "<SKProduct: 0x16df4e10>",
    "<SKProduct: 0x16df5400>",
    "<SKProduct: 0x16df54a0>",
    "<SKProduct: 0x16df5670>"
)

//Exception raised after that

Unity 代码(仅显示相关代码)

void Start () {

        productsIDs = new string[]
        {
            "com.company.coinpack1",
            "com.company.coinpack2",
            "com.company.coinpack3",
            "com.company.coinpack4",
            "com.company.coinpack5"


        };

        OnEnable ();
        StoreKitBinding.requestProductData(productsIDs);

    }

void OnEnable()
    {
        // Listens to all the StoreKit events. All event listeners MUST be removed before this object is disposed!
        StoreKitManager.transactionUpdatedEvent += transactionUpdatedEvent;
        //StoreKitManager.productPurchaseAwaitingConfirmationEvent += productPurchaseAwaitingConfirmationEvent;
        StoreKitManager.purchaseSuccessfulEvent += purchaseSuccessfulEvent;
        StoreKitManager.purchaseCancelledEvent += purchaseCancelledEvent;
        StoreKitManager.purchaseFailedEvent += purchaseFailedEvent;
        StoreKitManager.productListReceivedEvent += productListReceivedEvent;
        StoreKitManager.productListRequestFailedEvent += productListRequestFailedEvent;

        StoreKitBinding.enableHighDetailLogs (true);

//      StoreKitManager.restoreTransactionsFailedEvent += restoreTransactionsFailedEvent;
//      StoreKitManager.restoreTransactionsFinishedEvent += restoreTransactionsFinishedEvent;
    }

void productListReceivedEvent( List<StoreKitProduct> productList )
    {
        if (productList == null) {

            print("**** It's null!!!!");
            return;
                }

        Debug.Log( "productListReceivedEvent. total products received: " + productList.Count );

        // print the products to the console
        foreach( StoreKitProduct product in productList )
            Debug.Log( product.ToString() + "\n" );
    }


    void productListRequestFailedEvent( string error )
    {
        Debug.Log( "productListRequestFailedEvent: " + error );
    }
4

2 回答 2

1

这是 MonoBehavior 生命周期的图表,它应该派上用场,上面写着 unity 3.4,但它仍然几乎相同

单一行为生命周期

于 2014-09-02T16:27:59.023 回答
0

我的代码很好。问题是因为我的越狱设备。我在其他设备上测试了我的代码,它运行良好。

于 2014-09-02T20:06:03.510 回答