1.1 --- a/lib/DDInvocationGrabber.m Tue Jan 27 16:05:23 2009 -0600
1.2 +++ b/lib/DDInvocationGrabber.m Thu Feb 12 17:20:13 2009 -0600
1.3 @@ -72,6 +72,7 @@
1.4 _target = nil;
1.5 _invocation = nil;
1.6 _forwardInvokesOnMainThread = NO;
1.7 + _invocationThread = nil;
1.8 _waitUntilDone = NO;
1.9
1.10 return self;
1.11 @@ -125,6 +126,13 @@
1.12 _forwardInvokesOnMainThread = forwardInvokesOnMainThread;
1.13 }
1.14
1.15 +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
1.16 +- (void)setInvokesOnThread:(NSThread *)thread;
1.17 +{
1.18 + _invocationThread = thread;
1.19 +}
1.20 +#endif
1.21 +
1.22 - (BOOL)waitUntilDone;
1.23 {
1.24 return _waitUntilDone;
1.25 @@ -146,14 +154,28 @@
1.26 {
1.27 [ioInvocation setTarget:[self target]];
1.28 [self setInvocation:ioInvocation];
1.29 + BOOL invokeOnOtherThread = _forwardInvokesOnMainThread || (_invocationThread != nil);
1.30 + if (invokeOnOtherThread && !_waitUntilDone)
1.31 + {
1.32 + [_invocation retainArguments];
1.33 + }
1.34 +
1.35 if (_forwardInvokesOnMainThread)
1.36 {
1.37 - if (!_waitUntilDone)
1.38 - [_invocation retainArguments];
1.39 [_invocation performSelectorOnMainThread:@selector(invoke)
1.40 withObject:nil
1.41 waitUntilDone:_waitUntilDone];
1.42 }
1.43 +
1.44 +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
1.45 + if (_invocationThread != nil)
1.46 + {
1.47 + [_invocation performSelector:@selector(invoke)
1.48 + onThread:_invocationThread
1.49 + withObject:nil
1.50 + waitUntilDone:_waitUntilDone];
1.51 + }
1.52 +#endif
1.53 }
1.54
1.55 @end