views:

194

answers:

2

What is the preferred method of checking for sanity in objective-c and cocoa?

+2  A: 

NSAssert(thisShouldBeTrue, @"Error message");

Bob Aman
+4  A: 

Near the top of a method, NSParameterAssert that necessary objects are not nil, indexes are in range, etc. Sometimes you can get these for free; for example, an indexed accessor backed by an array can let the underlying array do the asserting for it.

Peter Hosey