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

前端 未结 3 1976
情歌与酒
情歌与酒 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 19:52

    Private is just a way to define a category on an object. Does not mean much to Apple but I would recommend using a unique name whenever adding categories to well known libraries such as ones in the FoundationFramework. If your naming convention is a prefix of AV then add a category like this.

    @interface AViewController(AVPrivate);

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-21 20:18

    (Private) in this case deals with principles of Object Oriented Programming.

    This does not necessarily denote a Private API, which would violate the Apple iPhone Developer Agreement.

    Note: App Store approval is very black-box, so I can not guarantee that such code would not indeed result in rejection during the approval process.

    0 讨论(0)
提交回复
热议问题