When porting Java code to ObjC, how best to represent checked exceptions?

后端 未结 6 828
梦如初夏
梦如初夏 2021-02-09 01:08

I am working on porting a Java codebase to Cocoa/Objective-C for use on desktop Mac OS X. The Java code has lots and lots of methods with checked exceptions li

6条回答
  •  滥情空心
    2021-02-09 02:01

    You're correct that "out errors are generally the better solution for ObjC". Very rarely will you find an API in Cocoa that throws an exception (unless you haven't satisfied the preconditions for the API, but in that case, behavior is undefined by default).

    If you expect this code to live beyond you and be adopted by other Cocoa developers, I would recommend using out errors. I work on code that was built by people unfamiliar with Cocoa and who used exceptions liberally, and they're a royal pain to work around.

提交回复
热议问题