Skip to content

Commit

Permalink
Merge pull request #156 from calabash/feature/fix-unrecognized-select…
Browse files Browse the repository at this point in the history
…or-crash-accessibilityLabel-on-UIMessageUITextFieldAccessibility

Try/Catch around LPInvoker invokeSelector:withTarget:
  • Loading branch information
jmoody committed Apr 30, 2015
2 parents 089b08e + 9c67214 commit 1806f12
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions calabash/Classes/Utils/LPInvoker.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,22 @@ + (id) invokeSelector:(SEL) selector withTarget:(id) target {
if ([invoker selectorReturnsObject]) {
NSInvocation *invocation = invoker.invocation;

void *buffer;

[invocation invoke];
[invocation getReturnValue:&buffer];

id result = (__bridge id)buffer;
id result = nil;

@try {
void *buffer;
[invocation invoke];
[invocation getReturnValue:&buffer];
result = (__bridge id)buffer;
} @catch (NSException *exception) {
NSLog(@"LPInvoker caught an exception: %@", exception);
NSLog(@"=== INVOCATION DETAILS ===");
NSLog(@"target = %@", target);
NSLog(@"target class = %@", [target class]);
NSLog(@"selector = %@", NSStringFromSelector(selector));
NSLog(@"target responds to selector: %@", [target respondsToSelector:selector] ? @"YES" : @"NO");
result = nil;
}

if(!result) {
return [NSNull null];
Expand Down

0 comments on commit 1806f12

Please sign in to comment.