Last active
August 29, 2015 14:20
-
-
Save Goles/5467d4476b982da9a0b4 to your computer and use it in GitHub Desktop.
Revisions
-
Goles renamed this gist
Apr 28, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Goles created this gist
Apr 28, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ // Header @interface AnOperation : NSOperation @property (nonatomic, readonly) NSString *ifa; @property (nonatomic, assign) double timeInterval; @end // .m // Tries to access a property with an exponential back-off @implementation AnIFAOperation - (void)main { _timeInterval = 0.0; [NSTimer scheduledTimerWithTimeInterval:_timeInterval target:self selector:@selector(startWithTimer:) userInfo:nil repeats:NO]; [[NSRunLoop currentRunLoop] run]; } - (BOOL)isExecuting { if (!_ifa) { return YES; } return NO; } - (BOOL)isFinished { if (!_ifa) { return NO; } return YES; } - (NSString *)getIFA { return [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]; } -(void)startWithTimer:(NSTimer *)timer { if (!_ifa) { _ifa = [self getIFA]; if (!_ifa) { _timeInterval = _timeInterval >= 1.0 ? _timeInterval * 2.0 : 1.0; _timeInterval = MIN(60.0, _timeInterval); [NSTimer scheduledTimerWithTimeInterval:_timeInterval target:self selector:@selector(startWithTimer:) userInfo:nil repeats:NO]; } [timer invalidate]; } } @end