Running a block after a delay

So I was looking for a way to easily run a block of Objective-C code after a set delay time. I found a few ways to do it, but one blog post I found encapsulated it pretty well. Here is the URL of that blog post:

Delayed Blocks in Objective-C (link redacted)

Using the NSObject category from the blog post, I can now run my block after a delay by using something like this:

[self performBlock:^{ [self myMethod]; } afterDelay:2.0f];

This will come in handy for my next blog post, which I will try to do over the weekend. (Hint: think of unrolling view hierarchies…)

BTW, Happy Birthday to Jack Lambert, one of the greatest Kent State alumni ever.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.