NKAssetDownload返回nil实例

时间:2012-08-21 12:07:47

标签: iphone ios

我正在尝试创建报刊亭应用程序,但在尝试下载所选的pdf时,资产下载返回nil。 有什么问题?

 -(void)downloadIssueAtIndex:(NSInteger)index
    {
      NKLibrary *nkLib = [NKLibrary sharedLibrary];
      NKIssue *nkIssue = [nkLib issueWithName:[publisher nameOfIssueAtIndex:index]];                 

     if (nkIssue == nil)
     {
    nkIssue = [nkLib addIssueWithName:[publisher nameOfIssueAtIndex:index] date:[NSDate date]];  

    }
if ([nkIssue status] != NKIssueContentStatusNone)
    return;
NSLog(@"%@",nkIssue);
NSURL *downloadURL = [publisher contentURLForIssueWithName:nkIssue.name];
NSLog(@"%@",downloadURL);
if(!downloadURL) return;
NSURLRequest *req = [NSURLRequest requestWithURL:downloadURL];
NSLog(@"%@",req);
//req shows the correct url request

NKAssetDownload *assetDownload = [nkIssue addAssetWithRequest:req];
//assetDownload is nil

NSLog(@"%@",assetDownload);
 [assetDownload setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:
                            [NSNumber numberWithInt:index],@"Index",
                            nil]];
[assetDownload downloadWithDelegate:self];
}

1 个答案:

答案 0 :(得分:0)

我这是因为[NKLibrary sharedLibrary];也会返回nil。

也许您应该尝试将自己的应用添加到报亭,方法是将UINewsstandApp添加到Info.plist中,然后将其设置为YES