views:

147

answers:

4

What does Apple mean when they refer to private APIs?

+7  A: 

Undocumented API's, or API's they haven't explicitly exposed to the developer.

While you may access them, there is no guarentee that these API's will not change in future revisions to iOS, plus it's a sure fire way to get your app rejected.

Alan
By "may access them" you mean "Apple will reject your app for using them".
ceejayoz
Yeah. Lemme edit that :D
Alan
So you're not going to stumble apon them you really need to dig around for them - which is what the hackers do to change the background image etc etc correct?
TheLearner
A: 

They mean APIs that are for use by Apple only. Or to be more correct, generally NOT to be used by SDK developers.

manyxcxi
+1  A: 

A private API is usually a method call which isn't supposed to be called by third party developers. These calls are usually reserved for the vendor of the product/API (Apple), and are usually "private" because the implementation of them could change in the future - and if they let developers use them and the implementation changes, the application could break.

JimR
I think a more reasonable reason why they don't want private APIs being called is because their security-solution technology (DRM) and restrictions on things like tethering, and the App store signing technology depends on certain things remaining beyond your grasp, as an SDK developer.
Warren P
@Warren. no that's not it. It would be stupid to have DRM that relied on developers playing by the rules.
JeremyP
It is possible to violate those rules, and learn things which can help in root-kitting.
Warren P
+1  A: 

A private method is one that is used as an implementation detail rather than a [public] interface detail. In other languages where public and private methods are more enforceable, private methods typically cannot be called from anything other than the class that they are contained within. The purpose of which is to hide implementation details, or to prevent external reliance on implementation details. For example, NSArray probably has a number of private methods that deal with memory allocation and optimised storage for efficient access.

Objective-C does not have truly private methods; you are free to send whatever message you want to any object, and it may respond to it or it may not. At runtime, you are also able to inspect exactly which messages a class (and its instances) will respond to through a series of Objective-C Runtime API calls [that are publicly documented].

Some people attempt to use private methods to obtain program behaviour that is not possible with the publicly documented interface; perhaps as an optimisation, perhaps to do something that the API was never meant to do. It is easily possible because of Objective-C's dynamic nature and lack of true private methods.

As a side note; Apple typically use a leading underscore in method names to denote that it is private. Apple also state that method names beginning with an underscore are reserved for Apple only.

dreamlax