iOS Crash Report SKProductsRequest

有关

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response

方法无响应或者直接崩溃。

第一种情况:

在本类中调用

有可能是SKProductRequest的对象是否已被释放。

请求很可能需要几秒钟才能完成,并且这可能会超出委托对象的生命周期,因此尽可能需要确保它足够长时间。

将其设置为全局变量或者property (nonatomic, strong)。

第二种情况

不是在本类中直接使用ipa,而是新建helperIPA类调用内购,

需要在helper类实现单例

+ (类名 *)sharedPurchase {

    static 类名 * _sharedP = nil;

    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{

        _sharedP = [[类名 alloc] init];

    });

    return _sharedP;

}

ARC模式下,调用helper 类,会认为括号内方法执行完毕,系统直接回收SKProductRequest的对象。

猜你喜欢

转载自www.cnblogs.com/liup18/p/9255283.html