NSException raise:format: as the last statement in a method

后端 未结 3 437
滥情空心
滥情空心 2021-01-19 17:52

I have this method:

+ (MHTwitterParser*)createParser:(NSString*)format {
    if ([format compare:@\"json\"] == NSOrderedSame) {
        return [[MHJsonTwitt         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 18:40

    The warning is there simply because not every path through the code ends with a return statement which the compiler recognizes as potentially problematic. That said, you probably shouldn't be throwing an exception here and should instead be generating an NSError and returning nil. The differences between exceptions and errors in objective-c are explained here and here.

提交回复
热议问题