Undocumented Mac Calls

I am working on a pair of products for Mac, and in order to do what I need, I use some calls to undocumented methods in Mac Classes. like

IKImageView's

doRotate:(id) 

and

PDFDocument's

 (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate; 

How dangerous is it to use such methods? Is there any danger besides making Apple more inaccessible in the future?

+7
objective-c code-smell macos
source share
2 answers

It's not completely unheard of, but if you are going to use them in a software release, you have to make sure that you have crap together and thoroughly test each version of OS X before it comes out - because yes, Apple can do any number of things in the future edition (change the signature of the method, delete this method, introduce some subtle errors in the method, which works in all its use cases).

In any case, if you find something there that you cannot do with the existing API, you should request an improvement with Apple so that they know what they need to add.

+7
source share

To extract the interface, you can use the class-dump utility, which will give you a nice automatically generated header file of any MachO file. For example, to find the getPrintOperationForPrintInfo method, you can use the command:

 $ class-dump /System/Library/Frameworks/Quartz.framework/Frameworks/PDFKit.framework/PDFKit | fgrep getPrintOperationForPrintInfo 

What will give you:

 - (id)getPrintOperationForPrintInfo:(id)arg1 autoRotate:(BOOL)arg2; 
+4
source share

All Articles