urbanairship/phonegap-ua-push — pull request #6 by mhooge (2012-10-01 19:55:51+00:00)
Title: Lib 479 PhoneGap message forwarding

Changes in UAAppDelegateSurrogate

Additions:
UADefaultDelegateNilException

**forwardInvocation**
forwardInvocation now throws a UADefaultDelegateNilException if the defaultAppDelegate does not exist, which would be the result of a failed app delegate exchange. The reason for the exception is that when we check the two delegates to see if they respond to the selector being forwarded, we give preference to our surrogateDelegate, then forward to the defaultAppDelegate without checking for a response, which would be expected behavior. This should force didNotRespond exceptions to be thrown from the defaultAppDelegate (delegate provided by PhoneGap dev) when there is a problem.
If there was no exception thrown in the case of a nil defaultAppDelegate, errors would be more difficult to track down.

**methodSignatureForSelector**
methodSignatureForSelector now simply checks the classes in the following order an returns the first non nil result. Since method signatures are the same if the selectors are the same, and valid matching method signature will work.

Reference:
https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSMethodSignature_Class/Reference/Reference.html
https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtForwarding.html

Tests:

The bulk of the changes come from adding in logic tests. I added tests for respondsToSelector for each delegate plus on negative test. I added a NSObject+UASwizzle category that trims down JRSwizzle and replaces it with the bare minimum to support swizzling on iOS and ObjC 2.0. The bulk of the swizzling work in JRSwizzle is there to support multiple platforms. I annotated the header accordingly to credit JRSwizzle. Swizzling the method calls allows for checking the messaging between objects without using OCMock and introducing more dependencies to the project.