views:

122

answers:

2

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 common is it for Objective C programmers to use methods like this? How do you find out about them (other than Google)? How dangerous is it to use them? Is there a danger other than that Apple will make them no-longer available in some future rev, and so your program will break?

+6  A: 

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.

Chuck
Ok, I'd already done that for 2 of them... And I've gotten no response... I just submitted another for the most recent one I found...
Brian Postow
+2  A: 

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;
withaspoon