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?
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