-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
115 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// COSScript+Interval.h | ||
// Cocoa Script | ||
// | ||
// Created by August Mueller on 11/21/13. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <CocoaScript/COScript.h> | ||
|
||
@class COSInterval; | ||
|
||
@interface COScript (IntervalAdditions) | ||
- (void)cleanupIntervals; | ||
- (void)removeInterval:(COSInterval*)interval; | ||
@end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// COScript+Interval.m | ||
// Cocoa Script | ||
// | ||
// Created by August Mueller on 11/21/13. | ||
// | ||
// | ||
|
||
#import "COScript+Interval.h" | ||
#import "COSInterval.h" | ||
|
||
@implementation COScript (IntervalAdditions) | ||
|
||
- (void)addInterval:(COSInterval*)i { | ||
|
||
if (!_intervals) { | ||
_intervals = [NSMutableArray array]; | ||
} | ||
|
||
[_intervals addObject:i]; | ||
} | ||
|
||
- (void)cleanupIntervals { | ||
|
||
for (COSInterval *i in _intervals) { | ||
[i cancel]; | ||
} | ||
|
||
[_intervals removeAllObjects]; | ||
|
||
_intervals = nil; | ||
|
||
} | ||
|
||
- (void)removeInterval:(COSInterval*)interval { | ||
|
||
if ([_intervals indexOfObject:interval] == NSNotFound) { | ||
NSLog(@"Could not remove interval %@ because it is not in %@'s interval stack.", interval, self); | ||
return; | ||
} | ||
|
||
debug(@"removing %@", interval); | ||
|
||
[_intervals removeObject:interval]; | ||
} | ||
|
||
- (id)scheduleWithRepeatingInterval:(NSTimeInterval)i jsFunction:(MOJavaScriptObject *)jsFunction { | ||
|
||
COSInterval *cosi = [COSInterval scheduleWithInterval:i cocoaScript:self jsFunction:jsFunction repeat:YES]; | ||
[self addInterval:cosi]; | ||
|
||
return cosi; | ||
} | ||
|
||
- (id)scheduleWithInterval:(NSTimeInterval)i jsFunction:(MOJavaScriptObject *)jsFunction { | ||
|
||
COSInterval *cosi = [COSInterval scheduleWithInterval:i cocoaScript:self jsFunction:jsFunction repeat:NO]; | ||
[self addInterval:cosi]; | ||
|
||
return cosi; | ||
} | ||
|
||
|
||
@end |
This file contains 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 characters
This file contains 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 characters