I'm working on a couple of mac products, and in order to do what I need to do, I'm using some calls to undocumented methods on Mac Classes. Like
IKImageView's
开发者_运维知识库 doRotate:(id)
and
PDFDocument's
(NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate;
How dangerous is it to use methods like these? Is there a danger other than that Apple will make them no-longer available in some future rev?
It's not altogether unheard-of, but if you're going to use them in release software, you need to make absolutely sure you have your shit together and test every version of OS X extensively before it comes out — because yes, Apple could do any number of things in a future revision (change the method's signature, remove the method, introduce some subtle bug in the method that works in all of their use cases).
At any rate, if you find there's something you can't do with the existing API, you should file an enhancement request with Apple so they know it's something they need to add.
To extract an interface you can use the class-dump utility which will give you a nice auto-generated header file of any MachO file. For example, to find getPrintOperationForPrintInfo
method you can use the command:
$ class-dump /System/Library/Frameworks/Quartz.framework/Frameworks/PDFKit.framework/PDFKit | fgrep getPrintOperationForPrintInfo
Which will give you:
- (id)getPrintOperationForPrintInfo:(id)arg1 autoRotate:(BOOL)arg2;
精彩评论