Denoteone
Denoteone

Reputation: 4055

Xcode iphone event listener

I need guidance for the following concept:

My iOS app has a text/messaging feature... I want to create a class that checks a database every 2 mins for new data no matter where the user is at in the application. I am assuming I would create a new class and just include it on all of my other files.

Is that the best workflow for what I am trying to achieve?

Upvotes: 0

Views: 453

Answers (1)

Abhinav
Abhinav

Reputation: 38162

You can probably run a repeat NSTimer with defined frequency from your AppDelegate and in the implemented selector you can write your piece of code to check DB for new data and may be fire a notification if it finds new data. Then you can have any of your viewController listen to that notification to get their UI updated.

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(checkDBForUpdates) userInfo:nil repeats:YES];

Upvotes: 1

Related Questions