Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ USAGE
[weakSelf doSomething];
}];

REQUIREMENTS
============
RNTimer uses ARC. If your project doesn’t, set the `-fobjc-arc` flag for `RNTimer.m`.

BACKGROUND
==========
http://robnapier.net/blog/simple-gcd-timer-rntimer-762
7 changes: 5 additions & 2 deletions RNTimer/RNTimer.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
// DEALINGS IN THE SOFTWARE.
//


#import "RNTimer.h"
#import <Availability.h>

@interface RNTimer ()
@property (nonatomic, readwrite, copy) dispatch_block_t block;
@property (nonatomic, readwrite, assign) dispatch_source_t source;
@property (nonatomic, readwrite, strong) dispatch_source_t source;
@end

@implementation RNTimer
Expand Down Expand Up @@ -58,7 +58,10 @@ + (RNTimer *)repeatingTimerWithTimeInterval:(NSTimeInterval)seconds
- (void)invalidate {
if (self.source) {
dispatch_source_cancel(self.source);

#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0
dispatch_release(self.source);
#endif
self.source = nil;
}
self.block = nil;
Expand Down