In the previous post we added block based methods to UIAlertView and UIActionSheet. I’ve extended the same code with Category addition for NSObject that allows you to perform a block of code using a custom method called performBlock which works similar to performSelector.

    [self performBlock:^
     {
         NSLog(@"hi there!");
     }
     ];

So using a block, you can do a performSelector and provide the code right there without writing a separate method.

Source Code

The complete source code is available on Github here. Clone it or fork it or do whatever you want* with the code.
https://github.com/MugunthKumar/UIKitCategoryAdditions

Integrating it into your app

To add the code into your app, just clone the project and drag the folder MKAdditions into your project. Make sure to copy the added files. Start using the methods in the class right away.

Licensing

As always, you can do whatever you want with this code, whether commercial or non-commercial. But while you redistribute or enhance this code or for the repository, do maintain a link back to this blog post.

Follow me on Twitter