Understanding this use of “(Private)” in @interfac

2019-02-27 08:01发布

问题:

I've seen some code written this way:

@interface AViewController(Private)

I wanted to know if that (Private) means something when submitting to the App Store? What does it mean in general?

回答1:

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.



回答2:

(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.



回答3:

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);