Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undocumented Mac Calls

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?

like image 871
Brian Postow Avatar asked Mar 22 '10 15:03

Brian Postow


2 Answers

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.

like image 147
Chuck Avatar answered Nov 02 '22 12:11

Chuck


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;
like image 41
withaspoon Avatar answered Nov 02 '22 14:11

withaspoon