Skip to content

Latest commit

 

History

History
56 lines (29 loc) · 1.12 KB

README.md

File metadata and controls

56 lines (29 loc) · 1.12 KB

NullObjects

NullObjects is a library for building Null Objects in Objective-C. It's inspired by Ruby's Naught.

Adding NullObjects to your project

CocoaPods

CocoaPods is the best way to include NullObjects in your project.

Include pod 'NullObjects', '~> 0.0.1' to your Podfile.

Usage

NONull is a replacement for NSNull but it acts more similarity to nil. It never raises an exception when method is call.

Simple Null Object

#import <NullObjects/NullObjects.h>

id null = [NONull null];

[null foo]; // == nil

Blackhole

#import <NullObjects/NullObjects.h>

id null = [NONull blackhole];

[null foo]; // == [NONull blackhole]

Replacing NSNull

Some system libraries uses NSNull for represent null object. NONull can replace NSNull object:

#import <NullObjects/NullObjects.h>

[NSNull actAsNullObject];
[NSNull actAsBlackhole];