Sharing NSOperationQueue across View Controllers?

后端 未结 3 1862
北恋
北恋 2021-01-31 06:06

I\'m using an NSOperationQueue to manage HTTP connections (using ASI-HTTPRequest). Since I have multiple views and the need to have these different views requesting HTTP connect

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 06:57

    If you already have a pointer to a class that handles connections in each view/view controller, there's no reason you would also need to have a pointer to the operation queue.

    I suppose what you want to do is something like: a) view(Controller) hands url(+data) to server handling object, b) server handling objects creates operation and puts it in a queue that it and only it has a pointer to.

    It's hard to figure out why that didn't work if you don't provide more detail.

    I highly recommend taking a look at ASIHTTPRequest which provides a NetworkQueue class to handle this kind of task. It has several convenient delegate fields that lets you register to keep track of progress, know when a download or upload finished etc.

提交回复
热议问题