Rob
Rob

Reputation: 629

networkActivityIndicatorVisible logic issue

so my application connects to a URL (via URLConnectionDelegate), gathers data, which contains image URLs. It then connects to each and every image url (again, via URLConnectionDelegate), and gathers the images for each image.

Everything works perfect, couldn't be happier.

But the problem is that I can't really track the networkActivityIndicator. There are like, 100 connections going off at once, so I don't know when or how to set the networkActivityIndicator to turn off once the last image is done loading.

Does anyone have any suggestions without me having to redo a bunch of code?

Thanks for the help guys

Upvotes: 1

Views: 241

Answers (1)

Rob Napier
Rob Napier

Reputation: 299345

The typical solution is a singleton object that you call [NetworkMonitor increaseNetworkCount] and [NetworkMonitor decreaseNetworkCount] at the appropriate points.

The nicer solution is a toolkit like MKNetworkKit, which will handle this and a bunch of similar things for you (like managing your download queue, since 100 simultaneous connections is actually very bad on iOS).

Upvotes: 3

Related Questions