Method naming fun

so I’m working on a completely new version of AIKeychain, the class Adium uses to access the keychain. the new version is more of a wrapper of Keychain Services, the Carbon API for working with keychains.

my problem is how to deal with the error codes that Keychain Services returns. I don’t want to just throw away the errors, as they could be important (most of them anyway – does anybody think that SecKeychainGetVersion is likely to return an error?). neither do I want to throw an exception – handling exceptions makes for messy code. and returning BOOL is:

  1. not much better than throwing away the error completely – fine, it failed, but how?
  2. unwieldy, as it means that all the methods that return anything must return it by reference

the solution I currently have in place is to return an NSError by reference. this works well because:

  • the error can be ignored if desired (pass NULL).
  • the error contains the OSStatus returned by Keychain Services as its error code.

the problem with this is the method name. consider:

+ (BOOL)allowsUserInteractionError:(out NSError **)outError;

I don’t like how ‘Error:’ runs right up against the actual name of the method. ideas?

Comments are closed.