Get Updates By E-mail 

Article Written By:
Johann Dowa

Nifty Library Allowing You To Define Your Own Objective-C Literals

  •  
  •  
  •  
  •  
  •  

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:

UIColor *myColor = [UIColor colorWithRed:255.0f
                                    blue:(241.0f / 2555.0f)
                                   green:(35.0f / 255.0f)
                                   alpha:1.0f];

Into:

UIColor *myColor = $(#FFF123);

You can read more about OCUDL on Dustin’s blog.

You can find OCUDL on Github here.

A very nice addition to Objective-C.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments