1/** 2 * Copyright (c) 2015-present, Facebook, Inc. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. An additional grant 7 * of patent rights can be found in the PATENTS file in the same directory. 8 */ 9 10#import "AIRWeakTimerReference.h" 11 12@implementation AIRWeakTimerReference 13{ 14 __weak NSObject *_target; 15 SEL _selector; 16} 17 18 19- (instancetype)initWithTarget:(id)target andSelector:(SEL)selector { 20 self = [super init]; 21 if (self) { 22 _target = target; 23 _selector = selector; 24 } 25 return self; 26} 27 28 29- (void)timerDidFire:(NSTimer *)timer 30{ 31 if(_target) 32 { 33 [_target performSelector:_selector withObject:timer]; 34 } 35 else 36 { 37 [timer invalidate]; 38 } 39} 40 41 42@end 43