The iOS framework that grows only as fast as its documentation
Non-Empty Collection Testing


BOOL NIIsArrayWithObjects (id object)
BOOL NIIsSetWithObjects (id object)
BOOL NIIsStringWithAnyText (id object)


For testing whether a collection is of a certain type and is non-empty.

Simply calling -count on an object may not yield the expected results when enumerating it if certain assumptions are also made about the object's type. For example, if a JSON response returns a dictionary when you expected an array, casting the result to an NSArray and calling count will yield a positive value, but objectAtIndex: will crash the application. These methods provide a safer check for non-emptiness of collections.

Function Documentation


Tests if an object is a non-nil array which is not empty.

BOOL NIIsArrayWithObjects:(id)object;


Tests if an object is a non-nil set which is not empty.

BOOL NIIsSetWithObjects:(id)object;


Tests if an object is a non-nil string which is not empty.

BOOL NIIsStringWithAnyText:(id)object;