Skip to content

Instantly share code, notes, and snippets.

View coryalder's full-sized avatar

Cory Alder coryalder

View GitHub Profile
@brentsimmons
brentsimmons / EmptyChecks.m
Created July 28, 2012 19:06
Checking if an object is empty
BOOL RSIsEmpty(id obj) {
return obj == nil || obj == [NSNull null] || ([obj respondsToSelector:@selector(length)] && [(NSData *)obj length] == 0) || ([obj respondsToSelector:@selector(count)] && [obj count] == 0);
}
BOOL RSStringIsEmpty(NSString *s) {
/*22 Feb. 2011: added NSNull check. JSON parser can put a null where we expect a string, and NSNull throws an exception when checking length. Since [NSNull null] is, arguably, emptiness, it makes sense to include it.*/
return s == nil || (id)s == (id)[NSNull null] || [s length] == 0;
}
@johankool
johankool / KVStylesheet.m
Created April 18, 2011 05:32
Alternative approach to have consistent UILabel styling.
//
// KVStylesheet.m
// Koolistov
//
// Created by Johan Kool on 15-04-2011.
// Copyright 2011 Koolistov. Use as you desire.
//
#import "KVStylesheet.h"