【iOS】手动抛出异常

 

之前没遇到过需要手动抛出异常的时候,这次见到了,记录一下。示例代码如下:

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

 

posted @ 2016-04-16 14:17  WriteOnRead  阅读(704)  评论(0编辑  收藏  举报