With iOS 6, and Xcode 4.4 a number of Objective-C literals were added reducing the code needed to define an NSArray, NSDictionary or NSNumber.
Here’s a library that allows you to add user defined literals to Objective-C called OCUDL from Dustin Bachrach.
You can create literals both by applying an implementing the included protocol, or on a specific block of code so you can turn just about anything into a literal.
There are also a number of defined literals included for UIImage, UIColor, UIStoryboard and more.
As Justin explains on his site you can turn some code such as:
blue:(241.0f / 2555.0f)
green:(35.0f / 255.0f)
alpha:1.0f];
Into:
You can read more about OCUDL on Dustin’s blog.
You can find OCUDL on Github here.
A very nice addition to Objective-C.
- Objective-C Additions For Ruby Like Iterators And More
- Nifty Core Data Editor Tool Updates With New Features (Trial Available)
- Open Source Objective-C Library Allowing You To Inject A Block Of Code Before/After Methods
- Best Resources In iOS Development – May 20th, 2012
- Library Allowing You To Emulate The iOS 7 Home Screen Image Parallax Tilt Effect
Original article: Nifty Library Allowing You To Define Your Own Objective-C Literals
©2013 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.




