Reputation: 6038
I'm trying to do something quite simple : Stopping a parse.com
query after a few seconds, with an NSTimer
. I've read after some reasearch it's a good "trick" to use.
Here is how I create my timer :
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:6.0
target:self
selector:@selector(stopRetries:)
userInfo:@{@"query":query}
repeats:NO];
Because i'm running this on a background thread (and outside a viewcontroller class), the timer is inside a dispatch_sync(dispatch_get_main_queue());
But whatever I do, I cannot stop the query, because [query cancel]
doesn't do anything. I can't pass it in the userInfo
of the timer. Breakpoints show it has an address and is "there" but it looks like junk inside.
What can I be doing wrong and what should I be doing instead?
My main goal is to make the parse.com
query stop faster than 30 seconds, and warn the user with an alert.
Upvotes: 1
Views: 292
Reputation: 402
You can Try this [self performSelector:@selector(abc) withObject:nil afterDelay:6.0];
or
You can Invalidate the timer
Upvotes: 1