Best way to define private methods for a class in Objective-C

后端 未结 12 1923
小鲜肉
小鲜肉 2020-11-22 14:34

I just started programming Objective-C and, having a background in Java, wonder how people writing Objective-C programs deal with private methods.

I understand there

12条回答
  •  一向
    一向 (楼主)
    2020-11-22 15:27

    There is a benefit of private methods absence. You can move the logic that you intended to hide to the separate class and use it as delegate. In this case you can mark delegate object as private and it will not be visible from outside. Moving logic to the separate class (maybe several) makes better design of your project. Cause your classes become simpler and your methods are grouped in classes with proper names.

提交回复
热议问题