Reputation: 157
I am working on a chat client. To get new messages (or post new one) I have to perform GET (or POST) request. All new messages are stored via core data. At the moment I don't know how to implement it in most optimal way.
My thoughts:
Thanks in advance.
Upvotes: 0
Views: 166
Reputation: 119031
Don't use performSelector afterDelay
. Using NSTimer
is much better (as the trigger for starting the next download). Also, use NSOperationQueue
to manage your background tasks. Create yourself a custom NSOperation
that you can instantiate and it will complete your request process. When you create a new operation to check for new messages, check if one is already in progress (there is no point having multiple requests in progress at the same time).
Other notes:
Upvotes: 1