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
Related posts:
- iOS Code: MKiCloudSync – Sync your NSUserDefaults to iCloud with a single line of code Just wrote this class, MKiCloudSync (100 lines of code) that...
- In App Purchases: Troubleshooting Code=0 “Cannot connect to iTunes Store” (SKErrorUnknown) When using MKStoreKit or any other equivalent framework or regular...
- ARC retain cycles and blocks I wrote a method to add blocks based completion handler...

Pingback: Blocks Party at Under The Bridge