Skip to content

Commit e4a78a9

Browse files
committed
Merge branch 'master' into travis
2 parents 9f1a8a5 + b678a55 commit e4a78a9

File tree

10 files changed

+259
-21
lines changed

10 files changed

+259
-21
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### master
2+
3+
- Refactoring (Removed NSTimerActor. Used CFRunLoopTimerCreateWithHandler instead.) #22 @Austinate
4+
- Added support for Swift Package Manager
5+
16
### 1.3.0 (2016-02-29)
27

38
- Add Carthage support

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PackageDescription
22

33
let package = Package(
4-
exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h"],
4+
exclude: ["Sources/Info.plist", "Sources/SwiftyTimer.h", "SwiftyTimerTests"],
55
dependencies: []
66
)

Sources/SwiftyTimer.swift

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,31 @@
2424

2525
import Foundation
2626

27-
private class NSTimerActor {
28-
let block: () -> Void
29-
30-
init(_ block: () -> Void) {
31-
self.block = block
32-
}
33-
34-
@objc func fire() {
35-
block()
36-
}
37-
}
38-
3927
extension NSTimer {
4028
/// Create a timer that will call `block` once after the specified time.
4129
///
4230
/// - Note: The timer won't fire until it's scheduled on the run loop.
4331
/// Use `NSTimer.after` to create and schedule a timer in one step.
4432
/// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947)
45-
33+
4634
public class func new(after interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
47-
let actor = NSTimerActor(block)
48-
return self.init(timeInterval: interval, target: actor, selector: "fire", userInfo: nil, repeats: false)
35+
return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0) { _ in
36+
block()
37+
}
4938
}
50-
5139
/// Create a timer that will call `block` repeatedly in specified time intervals.
5240
///
5341
/// - Note: The timer won't fire until it's scheduled on the run loop.
5442
/// Use `NSTimer.after` to create and schedule a timer in one step.
5543
/// - Note: The `new` class function is a workaround for a crashing bug when using convenience initializers (rdar://18720947)
56-
44+
5745
public class func new(every interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
58-
let actor = NSTimerActor(block)
59-
return self.init(timeInterval: interval, target: actor, selector: "fire", userInfo: nil, repeats: true)
46+
return CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, interval, 0, 0) { _ in
47+
block()
48+
}
6049
}
61-
50+
51+
6252
/// Create and schedule a timer that will call `block` once after the specified time.
6353

6454
public class func after(interval: NSTimeInterval, _ block: () -> Void) -> NSTimer {
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0720"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES"
15+
hideIssues = "NO">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "6E7E40891C84B1A20030CEBB"
19+
BuildableName = "SwiftyTimer.framework"
20+
BlueprintName = "SwiftyTimer OS X"
21+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<Testables>
32+
</Testables>
33+
<AdditionalOptions>
34+
</AdditionalOptions>
35+
</TestAction>
36+
<LaunchAction
37+
buildConfiguration = "Debug"
38+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
39+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
launchStyle = "0"
41+
useCustomWorkingDirectory = "NO"
42+
ignoresPersistentStateOnLaunch = "NO"
43+
debugDocumentVersioning = "YES"
44+
debugServiceExtension = "internal"
45+
allowLocationSimulation = "YES">
46+
<MacroExpansion>
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "6E7E40891C84B1A20030CEBB"
50+
BuildableName = "SwiftyTimer.framework"
51+
BlueprintName = "SwiftyTimer OS X"
52+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
53+
</BuildableReference>
54+
</MacroExpansion>
55+
<AdditionalOptions>
56+
</AdditionalOptions>
57+
</LaunchAction>
58+
<ProfileAction
59+
buildConfiguration = "Release"
60+
shouldUseLaunchSchemeArgsEnv = "YES"
61+
savedToolIdentifier = ""
62+
useCustomWorkingDirectory = "NO"
63+
debugDocumentVersioning = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "6E7E40891C84B1A20030CEBB"
68+
BuildableName = "SwiftyTimer.framework"
69+
BlueprintName = "SwiftyTimer OS X"
70+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
</ProfileAction>
74+
<AnalyzeAction
75+
buildConfiguration = "Debug">
76+
</AnalyzeAction>
77+
<ArchiveAction
78+
buildConfiguration = "Release"
79+
revealArchiveInOrganizer = "YES">
80+
</ArchiveAction>
81+
</Scheme>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0720"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES"
15+
hideIssues = "NO">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "6E7E40991C84B3790030CEBB"
19+
BuildableName = "SwiftyTimer.framework"
20+
BlueprintName = "SwiftyTimer tvOS"
21+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<Testables>
32+
</Testables>
33+
<AdditionalOptions>
34+
</AdditionalOptions>
35+
</TestAction>
36+
<LaunchAction
37+
buildConfiguration = "Debug"
38+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
39+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
launchStyle = "0"
41+
useCustomWorkingDirectory = "NO"
42+
ignoresPersistentStateOnLaunch = "NO"
43+
debugDocumentVersioning = "YES"
44+
debugServiceExtension = "internal"
45+
allowLocationSimulation = "YES">
46+
<MacroExpansion>
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "6E7E40991C84B3790030CEBB"
50+
BuildableName = "SwiftyTimer.framework"
51+
BlueprintName = "SwiftyTimer tvOS"
52+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
53+
</BuildableReference>
54+
</MacroExpansion>
55+
<AdditionalOptions>
56+
</AdditionalOptions>
57+
</LaunchAction>
58+
<ProfileAction
59+
buildConfiguration = "Release"
60+
shouldUseLaunchSchemeArgsEnv = "YES"
61+
savedToolIdentifier = ""
62+
useCustomWorkingDirectory = "NO"
63+
debugDocumentVersioning = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "6E7E40991C84B3790030CEBB"
68+
BuildableName = "SwiftyTimer.framework"
69+
BlueprintName = "SwiftyTimer tvOS"
70+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
</ProfileAction>
74+
<AnalyzeAction
75+
buildConfiguration = "Debug">
76+
</AnalyzeAction>
77+
<ArchiveAction
78+
buildConfiguration = "Release"
79+
revealArchiveInOrganizer = "YES">
80+
</ArchiveAction>
81+
</Scheme>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0720"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES"
15+
hideIssues = "NO">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "6E7E40A71C84B4240030CEBB"
19+
BuildableName = "SwiftyTimer.framework"
20+
BlueprintName = "SwiftyTimer watchOS"
21+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES">
31+
<Testables>
32+
</Testables>
33+
<AdditionalOptions>
34+
</AdditionalOptions>
35+
</TestAction>
36+
<LaunchAction
37+
buildConfiguration = "Debug"
38+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
39+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
launchStyle = "0"
41+
useCustomWorkingDirectory = "NO"
42+
ignoresPersistentStateOnLaunch = "NO"
43+
debugDocumentVersioning = "YES"
44+
debugServiceExtension = "internal"
45+
allowLocationSimulation = "YES">
46+
<MacroExpansion>
47+
<BuildableReference
48+
BuildableIdentifier = "primary"
49+
BlueprintIdentifier = "6E7E40A71C84B4240030CEBB"
50+
BuildableName = "SwiftyTimer.framework"
51+
BlueprintName = "SwiftyTimer watchOS"
52+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
53+
</BuildableReference>
54+
</MacroExpansion>
55+
<AdditionalOptions>
56+
</AdditionalOptions>
57+
</LaunchAction>
58+
<ProfileAction
59+
buildConfiguration = "Release"
60+
shouldUseLaunchSchemeArgsEnv = "YES"
61+
savedToolIdentifier = ""
62+
useCustomWorkingDirectory = "NO"
63+
debugDocumentVersioning = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "6E7E40A71C84B4240030CEBB"
68+
BuildableName = "SwiftyTimer.framework"
69+
BlueprintName = "SwiftyTimer watchOS"
70+
ReferencedContainer = "container:SwiftyTimer.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
</ProfileAction>
74+
<AnalyzeAction
75+
buildConfiguration = "Debug">
76+
</AnalyzeAction>
77+
<ArchiveAction
78+
buildConfiguration = "Release"
79+
revealArchiveInOrganizer = "YES">
80+
</ArchiveAction>
81+
</Scheme>

Tests/SwiftyTimerTests.xcodeproj/project.pbxproj renamed to SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.pbxproj

File renamed without changes.

Tests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata renamed to SwiftyTimerTests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)