2

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?

jscs
  • 63,694
  • 13
  • 151
  • 195
pmerino
  • 5,900
  • 11
  • 57
  • 76

3 Answers3

7

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.

Abizern
  • 146,289
  • 39
  • 203
  • 257
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.

Jason McCreary
  • 71,546
  • 23
  • 135
  • 174
  • This answer is very misleading. There are no best practices that say that Categories created for hiding private methods be named Private. And in any case I don't see what that has to do with inheritance or the App store. – Perception Jun 28 '11 at 21:07
  • @Perception, *inheritance* may have been the wrong OOP principle to reference. Nonetheless, the OP's concern dealt with App Store approval. So my focus was on defining the word *private*. Not sure why that makes my answer *misleading*. However, **Abizern** has a more thorough answer focusing on `(Private)`. – Jason McCreary Jun 28 '11 at 21:24
  • @Jason, you are correct in that the OP referenced the App store in question. – Perception Jun 28 '11 at 21:31
  • @Perception, you seem to have strong *opinion* on the matter. Why don't you supply an answer? – Jason McCreary Jun 29 '11 at 02:10
  • @Perception, I see that. I gave due credit as well. That doesn't mean you need to trash other answers though. I focused on the user's concern regarding App Store approval, not the specifics of using `(Private)`. You made a bold statement, I'm giving you the chance to back it up. If something's *misleading* about my answer, let's correct it. That's the whole point of SO. – Jason McCreary Jun 29 '11 at 02:30
  • @Perception let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/965/discussion-between-jason-mccreary-and-perception) – Jason McCreary Jun 29 '11 at 13:23
1

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

Joe
  • 56,979
  • 9
  • 128
  • 135