NSAssert results seem strange


I altered the designated initializer to actually cause the exception to be thrown as directed near the bottom of page 61, the code currently looks like this:

[code]// Designated initializer
-(id) initWithEntryDate:(NSDate *)theDate {

self = [super init];
if (self) {
    NSAssert(theDate == nil, @"Argument must be non-nil"); // purposefully throw an error
    entryDate = theDate;
    firstNumber = ((int)random() % 100) + 1;
    secondNumber = ((int)random() % 100) + 1;
return self;

The assert works but the console output seems strange:2011-11-22 20:33:37.691 lottery[12009:707] *** Assertion failure in -[LotteryEntry initWithEntryDate:], /Users/loumaag/Documents/Apple Developer/Programming/BigNerdRanch/Cocoa Programming/lottery/lottery/LotteryEntry.m:18 (gdb) Notice there is no message displayed and indeed the NSAssert is in line 18 of the code.

If I continue the execution then I get the exception notification which contains the expected message: 2011-11-22 20:35:52.729 lottery[12009:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil' *** First throw call stack: ( 0 CoreFoundation 0x00007fff895ad286 __exceptionPreprocess + 198 1 libobjc.A.dylib 0x00007fff8bdcad5e objc_exception_throw + 43 2 CoreFoundation 0x00007fff895ad0ba +[NSException raise:format:arguments:] + 106 <SNIP>
Is this the actual way this is supposed to function or have I got some setting fouled up that is causing that pause in execution before the actual exception is logged?


Well I feel a little silly. :blush:

It pays to actually read those little messages that Xcode throw up there. It was pausing because of a breakpoint set, the one we set on the previous page! I guess I was just not interpreting what I saw on the output correctly.