Should my Block-based API have just completion or both success and failure handlers?

后端 未结 3 1868
闹比i
闹比i 2021-02-02 17:22

When designing a block-based API in ObjC, which approach is better, one completion block or two, one each for success and failure?

Let\'s say we have a method retrieving

3条回答
  •  野性不改
    2021-02-02 18:14

    In my opinion it's very subjective. Thinking of use case scenarios for your API would the user benefit more from a completion or success/fail?

    If its something like a network access API ala AFNetworking probably go with success/fail - its more appropriate. However if the API is likely to finish successfully every time i.e. an animation block then completion is best

提交回复
热议问题