SSZipArchive无法使用In-App

时间:2014-07-07 09:13:07

标签: ios xcode in-app-purchase unzip

我创建了一个列表,通过Apple托管的In-App Purchase下载产品,但是当购买和下载SSZipArchive的包内容时,这是我的代码:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {

    for (SKPaymentTransaction * transaction in transactions) {

        switch (transaction.transactionState) {

            case SKPaymentTransactionStatePurchased:

                [[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];

                [self completeTransaction:transaction];

                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}

这里我试图解压缩我的包

- (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads {

    NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

    for (SKDownload *download in downloads)
    {

        switch (download.downloadState) {

            case SKDownloadStateActive:
                NSLog(@"Download progress %f", download.progress);
                NSLog(@"Download time  %f", download.timeRemaining);
                break;

            case SKDownloadStateFinished:

                NSLog(@"Finished!!");
                NSLog(@"Content URL  %@", download.contentURL);

                [SSZipArchive unzipFileAtPath:[NSString stringWithFormat:@"%@",download.contentURL] toDestination:docsDir];

                break;

            case SKDownloadStateFailed:
                NSLog(@"Failed");
                break;
            case SKDownloadStateCancelled:

                NSLog (@"Cancelled");
                break;
            case SKDownloadStatePaused:
            case SKDownloadStateWaiting:
                break;

            default:
                break;
        }
    }
}

我在哪里做错了?

使用本教程解决了THX:tutorial here

0 个答案:

没有答案