为什么要主动闪退
比如自己写了一个Class,然后开放了一个**initWithTitle:**的接口,但是总有像我一样的挫B不看头文件就开始写程序,程序运行起来不正常查半天还不知道为啥,所以干脆主动闪退告诉别人
小子! 用我写的类
如何主动闪退
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"提示信息" userInfo:nil];
通过丢出一个异常,来让App闪退,第一个参数Name,是一些系统定义的常量字符串
/*************** Generic Exception names ***************/
FOUNDATION_EXPORT NSString * const NSGenericException;
FOUNDATION_EXPORT NSString * const NSRangeException;
FOUNDATION_EXPORT NSString * const NSInvalidArgumentException;
FOUNDATION_EXPORT NSString * const NSInternalInconsistencyException;
FOUNDATION_EXPORT NSString * const NSMallocException;
FOUNDATION_EXPORT NSString * const NSObjectInaccessibleException;
FOUNDATION_EXPORT NSString * const NSObjectNotAvailableException;
FOUNDATION_EXPORT NSString * const NSDestinationInvalidException;
FOUNDATION_EXPORT NSString * const NSPortTimeoutException;
FOUNDATION_EXPORT NSString * const NSInvalidSendPortException;
FOUNDATION_EXPORT NSString * const NSInvalidReceivePortException;
FOUNDATION_EXPORT NSString * const NSPortSendException;
FOUNDATION_EXPORT NSString * const NSPortReceiveException;
FOUNDATION_EXPORT NSString * const NSOldStyleException;
如何配合使用
可以重写最终初始化方法**initWithFrame:和initWithCoder:**来进行条件检查,不满足就闪退!