IOS - Some Notes About Cocoa
First . Sometimes you will encounter such a situation , that your initiazer have to accept some parameters . You have to overwrite base class 'init' method :
- (id)init { [self dealloc]; @throw [NSException exceptionWithName:@"BNRBadInitCall" reason:@"Initialize Lawsuit with initWithDefendant:" userInfo:nil]; return nil; }
Second . Somethime you may not find out where the app crash , try the two methods below:
Method A : set a symbolic breakpoint at objc_exception_throw .
Method B : use NSAssert() to throw out the exceptions , for example :
- (id)initWithEntryDate:(NSCalendarDate *)theDate { if (![super init]) return nil; NSAssert(theDate == nil, @"Argument must be non-nil"); return self; }