-
Notifications
You must be signed in to change notification settings - Fork 26
Failure case only works by accident #15
Description
I know this code is really old, but some people are still using it.
-
(void) accessTokenTicket:(OAServiceTicket )ticket didFailWithError:(NSError *) error {
NSLog(@"access token did fail **************");[self performSelectorOnMainThread:@selector(callDelegateOnMainThreadWithAccessTokenTicket:didFailWithError:) withObject:error waitUntilDone:[NSThread isMainThread]];
} -
(void) callDelegateOnMainThreadWithAccessTokenTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *) error {
[self.delegate accessTokenTicket:ticket didFailWithError:error];
}
Notice that the call to performSelectorOnMainThread passes error in the withObject parameter. Notice that callDelegateOnMainThreadWithAccessTokenTicket expects error as the SECOND parameter.
The only reason this ever worked is because in
- (void) accessTokenTicket:(OAServiceTicket *)ticket didFailWithError:(NSError *) error {
takes 'error' as the second parameter, so it's already in the correct register (on ARM). The regs get saved to the stack, then they get pulled out later on, and miraculously, and thankfully, the error arg is in the right place. It crashes the simulator reliably, because the x86 calling standard generally passes parameters on the stack rather than in regs so you need to be a lot luckier to get things in the right place.