Accessing Private iOS Apis, How to? [closed]

放肆的年华 提交于 2019-12-07 20:54:07

问题


I would like to access some private APIs from the iOS SDK, related to the Camera like:

- (void)setExposureMode:(int)arg1;
- (int)exposureMode;

Etc. This is only for my personal development and I don't plan on submitting any Apps to the store. But I can't seem to figure out how to access and use these APIs. Is there any tutorial or book explaining the procedure?

For example, I tried adding this line to my .h file:

@interface AVCaptureDevice (Private)

- (void)setExposureMode:(int)arg1;

@end

But when I call this API from my App, it crashes. Even though respondsToSelector returns TRUE.

So could anyone link me to some good resources to learn about private API programming?


回答1:


What you are doing is syntactically almost correct.

The only issue is that in your category declaration you are using int instead of float. You might try and change this and see if things improve but I suspect the problem lies elsewhere.

With private API, no description is available about the way its methods should be used. So, maybe you are calling a method at the wrong time or in the wrong context. Possibly inspecting the crash log could give some insights.

One more thing, looking at your crash: possibly the fact that it is crashing is because the exposureMode you set is not supported. Try and use (ref):

- (BOOL)isExposureModeSupported:(AVCaptureExposureMode)exposureMode

to check it before hand (if your are not doing it already).



来源:https://stackoverflow.com/questions/12986849/accessing-private-ios-apis-how-to

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