开发者

Help getting NSURLConnection progress

The app is downloading a file (plist) which is generated by the server. The server takes a loooong time to generate the file, so I would like to be able to show progress (probably view UIProgressView, but that's not important).

Since the file I'm downloading hasn't been created yet at the beginning of the request, we don't know the expectedContentLength. However, I have the means to provide progress updates from the [PHP] script itself. I开发者_运维技巧'm using ob_flush() for each line in the file to do this, which works just fine in a browser.

But when I make the request from the app, I'm only getting a call from connection:didReceiveData: after the script has finished executing, so that's not of much use.

So my question boils down to this:

How can I tap into the progress of such a php script from my app?

I wouldn't mind sending 2 requests to the server, the first that generates the file and provides updates while doing so, and then another to download the actual file.

Since none of my NSUrlConnection delegate methods are being called until the request completes, what does my script need to do to trigger these methods?


Your problem is most likely on the server. If the server is sending data as it is processed and that processing takes a significant amount of time, you should probably get more than one notification of connection:didReceiveData:.

There is some discussion that might be relevant in the PHP manual. http://php.net/manual/en/function.ob-flush.php

I would verify using a packet analyzer that the server is actually sending data incrementally as you expect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜