Question

I'm normally able to work out why sigabrts happen, but i'm totally stuck on this one.. I'm launching the app from a remote notification, which all works fine until it gets to this bit of code:

NKIssue *issueNK = [[NKLibrary sharedLibrary] issueWithName:[issueId stringValue]]; 
if (issueNK == nil) {
    issueNK = [[NKLibrary sharedLibrary] addIssueWithName:[issueId stringValue] date:[NSDate date]];  
}

NSMutableDictionary* settings = [[[NSMutableDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]] autorelease];
NSURL *downloadURL = [NSURL URLWithString:
                      [NSString stringWithFormat:[settings objectForKey:@"IssueBundleUrl"], [issue.issueId intValue]]];
NSURLRequest *request = [NSURLRequest requestWithURL:downloadURL];
NKAssetDownload *assetDownload = [issueNK addAssetWithRequest:request]; //sigabrt on this line
[assetDownload downloadWithDelegate:issueListViewController];

in the debugger, issueNK and request both seem to be fine, not nil or anything.

any ideas? thanks.

Was it helpful?

Solution

I would guess that the only reason you would see an exception on that line, is if the issue has already been downloaded or is being downloaded. So you need to check the status of your issue first:

NKIssue *issueNK = [[NKLibrary sharedLibrary] issueWithName:[issueId stringValue]]; 
if (issueNK == nil) {
    issueNK = [[NKLibrary sharedLibrary] addIssueWithName:[issueId stringValue] date:[NSDate date]];  
}

if ([issueNK status] != NKIssueContentStatusNone)
    return;

NSMutableDictionary* settings = [[[NSMutableDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]] autorelease];
NSURL *downloadURL = [NSURL URLWithString:
                  [NSString stringWithFormat:[settings objectForKey:@"IssueBundleUrl"], [issue.issueId intValue]]];
NSURLRequest *request = [NSURLRequest requestWithURL:downloadURL];
NKAssetDownload *assetDownload = [issueNK addAssetWithRequest:request];
[assetDownload downloadWithDelegate:issueListViewController];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top