Understanding this use of “(Private)” in @interface declaration

前端 未结 3 1980
情歌与酒
情歌与酒 2021-01-21 19:38

I\'ve seen some code written this way:

@interface AViewController(Private)

I wanted to know if that (Private) means something when

3条回答
  •  暖寄归人
    2021-01-21 20:06

    It's a category called 'Private'.

    Have a look in the Categories and Extensions chapter of the Objective-C programming reference

    What it means is that it is an addition to the AViewControler class that has been named 'Private' for convenience. It could have been called anything or even left blank to create a class extension.

    You can create private methods in your own code that your app can call. This is actually good practice because it indicates proper encapsulation (although there is no such thing as a private method in Objective-C). What you aren't allowed to do is to use private methods of the iOS frameworks in your code if you don't want your app rejected from the App Store.

提交回复
热议问题