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

后端 未结 12 1903
小鲜肉
小鲜肉 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:19

    One more thing that I haven't seen mentioned here - Xcode supports .h files with "_private" in the name. Let's say you have a class MyClass - you have MyClass.m and MyClass.h and now you can also have MyClass_private.h. Xcode will recognize this and include it in the list of "Counterparts" in the Assistant Editor.

    //MyClass.m
    #import "MyClass.h"
    #import "MyClass_private.h"
    

提交回复
热议问题