1

当我从 App Store 下载内容时,它开始工作并显示

进度:0.000000

剩余:-1.000000

进度:0.000000

剩余:-1.000000

进度:0.750000

剩余:0.220680

最后显示失败。

这是我使用的代码

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction * transaction in transactions) {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
                break;
            case SKPaymentTransactionStateFailed:
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
                break;
            default:
                break;
        }
    };
}

-(void) paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads
{
    for (SKDownload *download in downloads)
    {
        switch (download.downloadState)
        {
            case SKDownloadStateActive:
            {
                NSLog(@"progress: %f", download.progress);
                NSLog(@"%f remaining", download.timeRemaining);
                break;
            }

            case SKDownloadStateCancelled: { break; }
            case SKDownloadStateFailed:
            {
                NSLog(@"faild");
                break;
            }

            case SKDownloadStateFinished:
            {
                NSString *source = [download.contentURL relativePath];
                NSDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:[source stringByAppendingPathComponent:@"ContentInfo.plist"]];

                NSLog(@"%@", dict); 

                [[SKPaymentQueue defaultQueue] finishTransaction:download.transaction];
                break;
            }

            case SKDownloadStatePaused:
            {
                NSLog(@"SKDownloadStatePaused");
                break;
            }

            case SKDownloadStateWaiting:
            {
                NSLog(@"SKDownloadStateWaiting");
                break;
            }
        }
    }

}

我现在如何获取文件?

4

0 回答 0