Guys I'm working on the Newsstand stuff now. I'm trying to handle network errors.
What you see on the image below is my simple log ("Percentage: %i" is inside connection:didWriteData:totalBytesWritten:expectedTotalBytes:
).
My problem is depicted in the last 3 lines of code.
What I've done in this lines:
- After that line I've switched on the airplane mode (simulated network error)
- I've received
connection:didWriteData:totalBytesWritten:expectedTotalBytes:
withtotalBytesWritten
equal toexpectedTotalBytes
- I've received
connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL
.
After that:
Hooray, I've just finished downloading my .zip, I can unpack it, announce the status to my view and so on... :(
My question is what's going on?
I have implemented connection:didFailWithError:
but it's not invoked.
I was trying to grab the totalBytesWritten
in last invoked didWriteData:
and compare it to real file size in DidFinishDownloading:
I have stripped all my project away just to make sure that its not related to my whole design.
I'm thinking about combination of NSTimer
and NKIssueContentStatusAvailable
to check the real download status.
It's all hacky. Isn't it?
Update:
- Reproduced on iOS 6 and 7 with XCode 5
- All NewsstandKit methods invoked on the main thread
- Same thing when simulating offline mode with Charles proxy (app in foreground)