Guest User

Untitled

a guest
Jun 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. @interface JTTimerProxy : NSProxy {
  2. id target;
  3. NSTimeInterval delay;
  4. }
  5. - (id)initWithTarget:(id)aTarget delay:(NSTimeInterval)aDelay;
  6. @end
  7.  
  8. @implementation JTTimerProxy
  9. - (id)initWithTarget:(id)aTarget delay:(NSTimeInterval)aDelay {
  10. target = aTarget;
  11. delay = aDelay;
  12. return self;
  13. }
  14. - (void)forwardInvocation:(NSInvocation *)anInvocation {
  15. [anInvocation setTarget:target];
  16. [NSTimer scheduledTimerWithTimeInterval:delay invocation:anInvocation repeats:NO];
  17. }
  18. - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
  19. return [target methodSignatureForSelector:aSelector];
  20. }
  21. @end
  22.  
  23. @interface NSObject (JTTimerProxy)
  24. - (NSProxy *)schedulerWithDelay:(NSTimeInterval)seconds;
  25. @end
  26.  
  27. @implementation NSObject (JTTimerProxy)
  28. - (NSProxy *)schedulerWithDelay:(NSTimeInterval)seconds {
  29. return [[[JTTimerProxy alloc] initWithTarget:self delay:seconds] autorelease];
  30. }
  31. @end
Add Comment
Please, Sign In to add comment