iPhone – Triggers events from multiple ViewControllers from one thread in AppDelegate

I have a NSAutoreleasePool thread that aims to extract information from a web service. I have very good web service code. I can trigger the thread to start in the view controller without any trouble. The fact is It works great on the above.

I want to:

>Move thread instantiation to appDelegate-simple!
>If you download new information, please run it regularly and tell the viewcontrollers (5-10) under it in some way
>has the ability to manually execute threads outside of the scheduler

I can use performSelectorOnMainThread to start a method on appdelegate but how do I make my child view controller “subscribe” to a method on appdelegate?

Using NSNotificationCenter, you can post a good notification: D
In this way, there is no appDelegate now other Classes can “subscribe” to the notifications they need.

In addition, I will keep the thread alive, each time a new thread is generated is expensive, only it is generated frequently. I recommend using GCD (iOS 4)

I have a NSAutoreleasePool thread that aims to extract information from a web service, I have good web service code, and I can trigger the thread in the view controller There is no trouble starting up, in fact it works very well.

I want to:

>Move thread instantiation to appDelegate-easy!
>If you download new information, please run it regularly and tell the viewcontrollers (5-10) under it in some way
>has the ability to manually execute threads outside of the scheduler

I can use performSelectorOnMainThread to start a method on appdelegate but how do I make my child view controller “subscribe” to a method on appdelegate?

Using NSNotificationCenter, you can publish good notifications: D
In this way, there is no appDelegate and now other classes can “subscribe” to the notifications they need.

In addition, I will keep the thread alive, each time spawning a new thread is expensive, only it is generated frequently. I recommend using GCD (iOS 4)

Leave a Comment

Your email address will not be published.