【iOS】手动抛出异常

 

以前没遇到过须要手动抛出异常的时候,此次见到了,记录一下。示例代码以下:ide

/** 若是调用 [[BNRItemStore alloc] init],就提示应该使用 [BNRItemStore sharedStore] */
- (instancetype)init {
    @throw [NSException exceptionWithName:@"Singleton"
                                   reason:@"Use + [BNRItemStore sharedStore]"
                                 userInfo:nil];
}