SKProductsRequest消息发送到解除分配的实例

时间:2014-11-25 19:56:58

标签: ios objective-c xcode

我遇到了很多类似的问题,尝试了一切,但无法让它发挥作用。有人可以帮我吗?

我的代码:

    @implementation DSInAppSubscriptionManager

- (void)requestProUpgradeProductData
{
    NSSet *productIdentifiers = [NSSet setWithObject:@"productID"];
    self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
    self.productsRequest.delegate = self;
    [self.productsRequest start];
}


- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
    NSArray *products = response.products;
    proUpgradeProduct = [products count] == 1 ? [products firstObject] : nil;
    if (proUpgradeProduct)
    {
        NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle);
        NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription);
        NSLog(@"Product price: %@" , proUpgradeProduct.price);
        NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier);
    }

    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }

}

-(void)requestDidFinish:(SKRequest *)request{
    NSLog(@"finished");
}
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error{
    NSLog(@"fail");
}

//-(void)dealloc{
//    self.productsRequest.delegate = nil;
//    [self.productsRequest cancel];
//    self.productsRequest = nil;
//}

@end

现在......用dealloc评论它给了我那条消息: *** - [DSInAppSubscriptionManager retain]:消息发送到解除分配的实例0x18742450

如果我取消注释dealloc方法,它不会显示该消息,但不会调用任何代表。

我从ViewController调用方法requestProUpgradeProductData。

1 个答案:

答案 0 :(得分:0)

我找到了答案......我正在将此类(DSInAppSubscriptionManager)实例化为我的viewController中的弱对象...所以当它调用委托时它已经被释放了......我的错误......