Nicholas Gibson
Nicholas Gibson

Reputation: 208

Stop Running @selector action

I am running:

[self performSelector:@selector(checkTheUsersText) withObject:nil afterDelay:0.01];

and as you can see it runs every 0.01 second! Is there a way to cancel that after it is finished. For example if the user dismisses the keyboard stop running (checkTheUsersText)? Thanks!

Upvotes: 0

Views: 235

Answers (1)

Yadvendar
Yadvendar

Reputation: 955

  • This wont run every 0.01 seconds, it will be called only once after a delay of 0.01 secs from the current time
  • Even if it gets called only once, you can again cancel the request using

    [NSObject cancelPreviousPerformRequestsWithTarget:self
                                         selector:@selector(checkTheUsersText)
                                           object:nil];
    

For more details please refer this

Upvotes: 2

Related Questions