これがクラッシュする関数です。コードの正確な行は、removeObjectForKey. テスト関数が完全に空の場合でも、removeObjectForKey でクラッシュします。注: 空の関数コールバックを渡しているだけです。現在、ARC をオフにしていますが、オンにする必要がありますか? 可能であれば、ARC をオフにして実行したいと考えています。ARC をオンにすると、多くのコンパイルの問題に対処することになるからです。
関数は保持されないオブジェクトについて何かを言うため、メモリの問題である可能性があります。
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    // So we got some receipt data. Now does it all check out?
    BOOL isOk = [self doesTransactionInfoMatchReceipt:responseString];
    VerifyCompletionHandler completionHandler = _completionHandlers[[NSValue valueWithNonretainedObject:connection]];
    [_completionHandlers removeObjectForKey:[NSValue valueWithNonretainedObject:connection]];
    if (isOk)
    {
        //Validation suceeded. Unlock content here.
        NSLog(@"Validation successful");
        completionHandler(TRUE);
    } else {
        NSLog(@"Validation failed");
        completionHandler(FALSE);
    }
}
ここでは、verificationController の使用法を示します。
    [[VerificationController sharedInstance] verifyPurchase:transaction completionHandler:^(BOOL success) {
        if (success) {
            NSLog(@"Hi, its success.");
            [self testMethod];
       } else {
            NSLog(@"payment not authorized.");
        }
    }];         
}
- (void) testMethod {
}
__weak を使用できますが、回避しようとしている ARC をオンにする必要があります。注:verificaitionControllerは、他のクラス/オブジェクト内に配置すると機能しますが、InAppPurchaseManagerに配置するとすぐに、自己にアクセスしようとすると爆発します。Self は、次のように定義された InAppPurchaseManager のインスタンスを指します (phonegap プラグイン)。
@interface InAppPurchaseManager : CDVPlugin <SKPaymentTransactionObserver> {
}