Objective C delegate or C-style block callback?

前端 未结 3 1390
花落未央
花落未央 2021-02-09 02:46

I am designing a class that will \"fire events\" whenever something occurs. These events tend to be non-UI related. I\'m wondering what the best method for doing so is. I\'ve be

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-09 03:04

    Using delegates means more tightly coupling in terms of architecture than using simple callback blocks. And for non-complex cases delegates can be an overkill.

    Storing blocks in some container is just ok, but you should think ahead about possibility of removing them at some point later (this will require some work), I mean an additional interface for removing of an already added handler.

提交回复
热议问题