git.iko.soy/metal-metaballs
on master help sign in
Refactored dispatch_after.
commit5b0bad6c8f55f80edf21798fd154dc11fb5317f3 authorvinivendra <vinivendra@gmail.com> dateThu 25 Feb 2016, 15:28 (11 years ago) parent9392fc7
3 files changed+11−1
PixelImage.xcodeproj/project.pbxproj+4 PixelImage/Dispatch.swift+6 PixelImage/ViewController.swift+1−1
PixelImage.xcodeproj/project.pbxproj+4
@@ -23,6 +23,7 @@
2323 24E1E7F11C67D74300ECF1C4 /* shaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = 24E1E7EF1C67D74300ECF1C4 /* shaders.metal */; };
2424 24ED21CD1C6C2397009C40FC /* MetaballDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24ED21CC1C6C2397009C40FC /* MetaballDataSource.swift */; };
2525 24FC38341C7F931E0085C04A /* Metaball.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FC38331C7F931E0085C04A /* Metaball.swift */; };
26+ 24FC38361C7F9ABE0085C04A /* Dispatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FC38351C7F9ABE0085C04A /* Dispatch.swift */; };
2627 24FFA86B1C6BA038005ACD60 /* ApproximationOperator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FFA84C1C6BA038005ACD60 /* ApproximationOperator.swift */; };
2728 24FFA86C1C6BA038005ACD60 /* Collections.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FFA84D1C6BA038005ACD60 /* Collections.swift */; };
2829 24FFA86D1C6BA038005ACD60 /* ComparatorChains.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FFA84E1C6BA038005ACD60 /* ComparatorChains.swift */; };
@@ -73,6 +74,7 @@
7374 24E1E7EF1C67D74300ECF1C4 /* shaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = shaders.metal; sourceTree = "<group>"; };
7475 24ED21CC1C6C2397009C40FC /* MetaballDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MetaballDataSource.swift; sourceTree = "<group>"; };
7576 24FC38331C7F931E0085C04A /* Metaball.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Metaball.swift; sourceTree = "<group>"; };
77+ 24FC38351C7F9ABE0085C04A /* Dispatch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dispatch.swift; sourceTree = "<group>"; };
7678 24FFA84C1C6BA038005ACD60 /* ApproximationOperator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApproximationOperator.swift; sourceTree = "<group>"; };
7779 24FFA84D1C6BA038005ACD60 /* Collections.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Collections.swift; sourceTree = "<group>"; };
7880 24FFA84E1C6BA038005ACD60 /* ComparatorChains.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ComparatorChains.swift; sourceTree = "<group>"; };
@@ -146,6 +148,7 @@
146148 24FFA84B1C6BA038005ACD60 /* SwiftSugar */,
147149 242686871C63B72A00D62456 /* AppDelegate.swift */,
148150 242686891C63B72A00D62456 /* ViewController.swift */,
151+ 24FC38351C7F9ABE0085C04A /* Dispatch.swift */,
149152 24FC38331C7F931E0085C04A /* Metaball.swift */,
150153 24E1E7D61C67C8B200ECF1C4 /* UIKit.swift */,
151154 246B0F821C70635D00A71D05 /* UIColor.swift */,
@@ -394,6 +397,7 @@
394397 24FFA8831C6BA038005ACD60 /* Slicing.swift in Sources */,
395398 24FFA8721C6BA038005ACD60 /* Sequence.swift in Sources */,
396399 24FFA87F1C6BA038005ACD60 /* Iterate.swift in Sources */,
400+ 24FC38361C7F9ABE0085C04A /* Dispatch.swift in Sources */,
397401 24FFA8761C6BA038005ACD60 /* Categorise.swift in Sources */,
398402 24FFA86D1C6BA038005ACD60 /* ComparatorChains.swift in Sources */,
399403 24FFA8711C6BA038005ACD60 /* PowerOperator.swift in Sources */,
PixelImage/Dispatch.swiftnew file+6
@@ -0,0 +1,6 @@
1+
2+import Dispatch
3+
4+func delay(duration: Float = 1, block: () -> ()) {
5+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(duration * Float(NSEC_PER_SEC))), dispatch_get_main_queue(), block)
6+}
PixelImage/ViewController.swift+1−1
@@ -56,7 +56,7 @@ class ViewController: UIViewController, MetaballDataSource {
5656
5757 addEdge(0, 2)
5858
59− dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * Int64(NSEC_PER_SEC)), dispatch_get_main_queue()) {
59+ delay {
6060 self.removeEdge(0, 2)
6161 }
6262