Watch out with assertions. Truth about NSAssert and assert functions in iOS.

Some good tips on using the assertions in IOS

Originally posted on lines of code:

This article points out differences between NSAssert and assert functions in Objective-C. Let’s go for it.

An assertion is a predicate (a true–false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. If an assertion evaluates to false at run-time, an assertion failure results, which typically causes execution to abort. – Wikipedia

We all know and use assertions. Or at least, we should. Most common are NSAssert and NSParameterAssert. Each thread has its own NSAssertionHandler object created for it. When invoked with an assertion, an NSAssertionHandler prints an error message that
includes the method and class (or function) containing the assertion and then it raises an
NSInternalInconsistencyException. There is also a assert() function defined in assert.h of the C Standard Library.

View original 180 more words