I want to call the getData method after waiting 2 seconds each time this loop…loops. I’ve written out the NSTimer a number of times inside and outside the loop but can’t get the correct usage for it to do what I want.
for (TwitterPerson *person in [tempDict allValues]) {
[self getDataFromTwitterUserAPIandArchiveFor:person.handle];
}
Could you set it up differently and call the
[getData...method every time the timer fires? You could keep your dictionary keys in an array and pop the next key each time the timer fired.I think the NSTimer is designed to not block the main thread whereas the
for-loopdefinitely blocks the thread.As in this related question Using NSTimer in a Loop, you might consider NSRunLoop.