What are private APIs
Asked Answered
A

4

16

What does Apple mean when they refer to private APIs?

Arcade answered 8/6, 2010 at 19:42 Comment(0)
H
21

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.

Horsy answered 8/6, 2010 at 19:44 Comment(7)
By "may access them" you mean "Apple will reject your app for using them".Archaeopteryx
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?Arcade
We dont submit source code to apple then how do they come to know that hte app is using private APIChemmy
They might not be able to detect if you've used undocumented apis, but if your app has features not available publically, that's typically how Apple will reject you. Plus if you use undocumented apis' the app can crash with newer versions of iOS, and crashing apps get teh boot.Horsy
@NileshTupe: They can examine the call stack of your application during its execution and see whether calls to private methods were invoked inside Apple's frameworks or from within one of your own methods.Nelidanelie
How do apps like facebook, snapchat or tinder exist? I can not imagine every endpoint is documented and open.Brainard
@JZ the context of the question refers to APIs in Apple's iPhone SDK. Other applications, such as facebook, can make use of their own private APIs. Just that no application can use undocumented/unpublic APIs that Apple provides.Horsy
N
6

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.

Nelidanelie answered 9/6, 2010 at 13:16 Comment(0)
O
1

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.

Obese answered 8/6, 2010 at 19:45 Comment(3)
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.Assyriology
@Warren. no that's not it. It would be stupid to have DRM that relied on developers playing by the rules.Evite
It is possible to violate those rules, and learn things which can help in root-kitting.Assyriology
M
0

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

Montiel answered 8/6, 2010 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.