Skip to content

Instantly share code, notes, and snippets.

@crowl
Created July 13, 2012 03:06
Show Gist options
  • Save crowl/3102432 to your computer and use it in GitHub Desktop.
Save crowl/3102432 to your computer and use it in GitHub Desktop.
NSDictionary category to deal with nil instead of NSNull objects created by NSJSONSerialization
//
// NSDictionary+NSNullUtility.h
//
//
// Created by Pablo Heredia on 12-07-12.
// Copyright (c) 2012. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSDictionary (NSNullUtility)
- (id)notNullObjectForKey:(id)aKey;
@end
//
// NSDictionary+NSNullUtility.h
//
//
// Created by Pablo Heredia on 12-07-12.
// Copyright (c) 2012. All rights reserved.
//
#import "NSDictionary+NSNullUtility.h"
@implementation NSDictionary (NSNullUtility)
- (id)notNullObjectForKey:(id)aKey
{
id object = [self objectForKey:aKey];
if (object == [NSNull null]) return nil;
return object;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment