What is the preferred method of checking for sanity in objective-c and cocoa?
+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
2009-04-15 07:47:47