iOS How to use private API?

廉价感情. 提交于 2019-11-30 13:58:10

Just specify the private methods in a category interface above the class implementation where you want to use it, like this:

@interface UIApplication (Private)

- (BOOL)launchApplicationWithIdentifier:(id)identifier suspended:(BOOL)suspended;

@end

Don't import the whole class-dump file and link with the original UIKit framework.

You must be very careful when using private API. These methods can change or be removed in future iOS versions!

Check if the method really exists with respondsToSelector: at runtime and be prepared for the case that it does not exist.

I used a secret MapKit feature in my own application and I knew that the private methods only exist in iOS 5. So my app still works in all iOS versions but this feature is only available in iOS 5 (Apple removed or changed it in iOS 6 beta 1).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!