PDA

View Full Version : Breaking Conditionally




teguh123
May 10, 2011, 12:48 PM
A variable shouldn't be nil. Say it's nil. How do I break the program when it's nil?

Debug assert? Objective c?



chown33
May 10, 2011, 01:00 PM
C assertions should work.
http://developer.apple.com/library/ios/#DOCUMENTATION/System/Conceptual/ManPages_iPhoneOS/man3/assert.3.html

Also look up NSAssert.

FWIW, google search terms: ios assert site:developer.apple.com


And see this:
http://vgable.com/blog/2008/12/04/nsassert-considered-harmful/

PhoneyDeveloper
May 10, 2011, 01:22 PM
I don't believe that the issue mentioned in the "NSAssert considered harmful" blog post applies on iOS. It does, kind of, on MacOS X.

I use NSAssert in both Mac and iOS code and it works as expected. I believe this is what OP should use.