Is it possible to cancel an NKAssetDownload?

♀尐吖头ヾ 提交于 2019-12-22 08:49:25

问题


I have a magazine reader on the App Store. I'm implementing NewsstandKit features at the moment.

My app has this download workflow where users can cancel current downloads at anytime.

I want to enable users to purchase an in-app product and begin that download as a newsstand background download (magazines include multimedia so they are kind of big files) but still preserve that option of they had on previous versions where they could cancel downloads.

Is it possible to achieve this with NKAssetDownload? Or should I remove the whole NKIssue instead?


回答1:


You should use this method on the asset :

- (void)removeIssue:(NKIssue *)issue

// Remove asset
[[NKLibrary sharedLibrary] removeIssue:[[NKLibrary sharedLibrary]
                           issueWithName:self.issues[indexPath.row][@"Name"]]];

Description from Apple documentation :
Removes the specified issue from the newsstand content library. When an issue is removed, any data at the file-system location identified by the issue’s content URL (accessed through the contentURL property of NKIssue) is deleted from disk. If you have issue content elsewhere in the application sandbox, it’s your responsibility to clean it up. Calling this method also cancels any asset downloads for that issue that are underway.

Source : http://developer.apple.com/library/ios/documentation/StoreKit/Reference/NKLibrary_Class/NKLibrary/NKLibrary.html#//apple_ref/doc/uid/TP40010835-CH2-SW2




回答2:


If you remove an issue, corresponding downloads will be canceled.

NKIssue *issue = [[NKLibrary sharedLibrary] issueWithName:editionName]; 
if (issue)
    [[NKLibrary sharedLibrary] removeIssue:issue];


来源:https://stackoverflow.com/questions/8646121/is-it-possible-to-cancel-an-nkassetdownload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!