Blocks in C and Objective-C are downright magical. They make coding easier and potentially quicker, not to mention faster on the front end with multithreading and Grand Central Dispatch. BlocksKit hopes to facilitate this kind of programming by removing some of the annoying - and, in some cases, impeding - limits on coding with blocks.
BlocksKit is a static library for iOS 3.2 and up. It can technically work on Mac OS X 10.6+ (with Chameleon for the UIKit stuff), but this project does not encompass that target at this time.
- Performing blocks on an
NSObject
. - Key-value observation (
<NSKeyValueObserving>
) using a block handler - Associated objects using an Obj-C API. (Not directly block-related.)
NSArray
,NSSet
, andNSDictionary
filter utilities- BKMacros, for more quickly typing out the above.
NSInvocation
creation using blocksNSTimer
block executionUIAlertView
,UIActionSheet
with block callbacks- Block initializers for
UIControl
andUIBarButtonItem
- Initializer for
UIGestureRecognizer
- On-touch utilities for
UIView
. - both delegation and block callbacks on
NSURLConnection
- Clone the repository.
- In Xcode 4, click-and-drag (or add using File > Add Files to Project) the BlocksKit XCode project into a project or workspace.
- In the build phases of a target, add libBlocksKit.a to the "Target Dependencies" and "Link Binary with Libraries".
- In the build settings, change "All Linker Flags" to
-ObjC -all_load
and "Header Search Paths" to$(BUILT_PRODUCTS_DIR)/../BlocksKit/**
. - If you are using Xcode 4.2 with the iOS 5.0 SDK on a non-ARC target, set "All Linker Flags" to
-ObjC -all_load -fobjc-arc
. - In any header file, insert
#import "BlocksKit/BlocksKit.h"
. This is a change from previous version. It is not recommended to insert the import statement in your project prefix, as it will break Xcode 4's Code Sense for the entire project.
Documentation is exhaustive and done using AppleDoc.
An Xcode 4 compatible documentation set is available using this Atom link. Add it to Xcode 4's preferences and it'll download automatically.
You can also view the documentation online at my website.
BlocksKit is created and maintained by Zachary Waldowski under the MIT license (hello, nice to meet you). All of the included code is licensed either under BSD, MIT, or is in the public domain. The project itself is free for use in any and all projects.
Unsure about your rights? Read more.
BlocksKit takes, repurposes, fiddles with, and groups together a variety of block-related code generally found here on GitHub.
The following people (in alphabetical order) have their code lovingly enshrined in BlocksKit:
- Michael Ash.
- Jiva DeVoe.
- Igor Evsukov.
- Corey Floyd.
- Landon Fuller.
- Mirko Kiefer.
- Robin Lu.
- Jake Marsh.
- Andy Matuschak.
- Aleks Nesterow.
- Kevin O'Neill.
- Jonathan Rentzch.
- Peter Steinberger.
- Jon Sterling.
- Martin Schürrer.
- Jonathan Wight.
Individual credits exist in the header files and, consequently, in the documentation.