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

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-10-29
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案