├── .gitignore ├── Demo ├── Demo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── Demo.xcworkspace │ └── contents.xcworkspacedata ├── Demo │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── DemoTests │ ├── DemoTests.swift │ └── Info.plist ├── Podfile └── Podfile.lock ├── Haste.podspec ├── LICENSE ├── NSTimer+Haste.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | Pods/ 27 | -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B48DAA45A771F37A4DEE236 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDD9E6CDDB113F12D7E3A05B /* Pods.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 11 | 5E4E74601A7C07A100F8C75F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E4E745F1A7C07A100F8C75F /* AppDelegate.swift */; }; 12 | 5E4E74621A7C07A100F8C75F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E4E74611A7C07A100F8C75F /* ViewController.swift */; }; 13 | 5E4E74651A7C07A100F8C75F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5E4E74631A7C07A100F8C75F /* Main.storyboard */; }; 14 | 5E4E74671A7C07A100F8C75F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5E4E74661A7C07A100F8C75F /* Images.xcassets */; }; 15 | 5E4E746A1A7C07A100F8C75F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5E4E74681A7C07A100F8C75F /* LaunchScreen.xib */; }; 16 | 5E4E74761A7C07A100F8C75F /* DemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5E4E74751A7C07A100F8C75F /* DemoTests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 5E4E74701A7C07A100F8C75F /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 5E4E74521A7C07A100F8C75F /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 5E4E74591A7C07A100F8C75F; 25 | remoteInfo = Demo; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 5E4E745A1A7C07A100F8C75F /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 5E4E745E1A7C07A100F8C75F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 5E4E745F1A7C07A100F8C75F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | 5E4E74611A7C07A100F8C75F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | 5E4E74641A7C07A100F8C75F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | 5E4E74661A7C07A100F8C75F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 36 | 5E4E74691A7C07A100F8C75F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 37 | 5E4E746F1A7C07A100F8C75F /* DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 5E4E74741A7C07A100F8C75F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 5E4E74751A7C07A100F8C75F /* DemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoTests.swift; sourceTree = ""; }; 40 | 6B90C7F7D8AC2DFF1C7E25B5 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; 41 | CDD9E6CDDB113F12D7E3A05B /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | F05DFE3F5147883D7B794D3F /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | 5E4E74571A7C07A100F8C75F /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 1B48DAA45A771F37A4DEE236 /* Pods.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | 5E4E746C1A7C07A100F8C75F /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 2895818367A029962F04EB03 /* Frameworks */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | CDD9E6CDDB113F12D7E3A05B /* Pods.framework */, 68 | ); 69 | name = Frameworks; 70 | sourceTree = ""; 71 | }; 72 | 5E4E74511A7C07A100F8C75F = { 73 | isa = PBXGroup; 74 | children = ( 75 | 5E4E745C1A7C07A100F8C75F /* Demo */, 76 | 5E4E74721A7C07A100F8C75F /* DemoTests */, 77 | 5E4E745B1A7C07A100F8C75F /* Products */, 78 | DDB5954A2E9EB13A0F8BBE81 /* Pods */, 79 | 2895818367A029962F04EB03 /* Frameworks */, 80 | ); 81 | sourceTree = ""; 82 | }; 83 | 5E4E745B1A7C07A100F8C75F /* Products */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 5E4E745A1A7C07A100F8C75F /* Demo.app */, 87 | 5E4E746F1A7C07A100F8C75F /* DemoTests.xctest */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | 5E4E745C1A7C07A100F8C75F /* Demo */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 5E4E745F1A7C07A100F8C75F /* AppDelegate.swift */, 96 | 5E4E74611A7C07A100F8C75F /* ViewController.swift */, 97 | 5E4E74631A7C07A100F8C75F /* Main.storyboard */, 98 | 5E4E74661A7C07A100F8C75F /* Images.xcassets */, 99 | 5E4E74681A7C07A100F8C75F /* LaunchScreen.xib */, 100 | 5E4E745D1A7C07A100F8C75F /* Supporting Files */, 101 | ); 102 | path = Demo; 103 | sourceTree = ""; 104 | }; 105 | 5E4E745D1A7C07A100F8C75F /* Supporting Files */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 5E4E745E1A7C07A100F8C75F /* Info.plist */, 109 | ); 110 | name = "Supporting Files"; 111 | sourceTree = ""; 112 | }; 113 | 5E4E74721A7C07A100F8C75F /* DemoTests */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 5E4E74751A7C07A100F8C75F /* DemoTests.swift */, 117 | 5E4E74731A7C07A100F8C75F /* Supporting Files */, 118 | ); 119 | path = DemoTests; 120 | sourceTree = ""; 121 | }; 122 | 5E4E74731A7C07A100F8C75F /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 5E4E74741A7C07A100F8C75F /* Info.plist */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | DDB5954A2E9EB13A0F8BBE81 /* Pods */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | F05DFE3F5147883D7B794D3F /* Pods.debug.xcconfig */, 134 | 6B90C7F7D8AC2DFF1C7E25B5 /* Pods.release.xcconfig */, 135 | ); 136 | name = Pods; 137 | sourceTree = ""; 138 | }; 139 | /* End PBXGroup section */ 140 | 141 | /* Begin PBXNativeTarget section */ 142 | 5E4E74591A7C07A100F8C75F /* Demo */ = { 143 | isa = PBXNativeTarget; 144 | buildConfigurationList = 5E4E74791A7C07A100F8C75F /* Build configuration list for PBXNativeTarget "Demo" */; 145 | buildPhases = ( 146 | 81A92F4445745454E45B6744 /* Check Pods Manifest.lock */, 147 | 5E4E74561A7C07A100F8C75F /* Sources */, 148 | 5E4E74571A7C07A100F8C75F /* Frameworks */, 149 | 5E4E74581A7C07A100F8C75F /* Resources */, 150 | B941E360083BE98EE2079AF6 /* Embed Pods Frameworks */, 151 | 27E9E65D44341397134E75A0 /* Copy Pods Resources */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = Demo; 158 | productName = Demo; 159 | productReference = 5E4E745A1A7C07A100F8C75F /* Demo.app */; 160 | productType = "com.apple.product-type.application"; 161 | }; 162 | 5E4E746E1A7C07A100F8C75F /* DemoTests */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 5E4E747C1A7C07A100F8C75F /* Build configuration list for PBXNativeTarget "DemoTests" */; 165 | buildPhases = ( 166 | 5E4E746B1A7C07A100F8C75F /* Sources */, 167 | 5E4E746C1A7C07A100F8C75F /* Frameworks */, 168 | 5E4E746D1A7C07A100F8C75F /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | 5E4E74711A7C07A100F8C75F /* PBXTargetDependency */, 174 | ); 175 | name = DemoTests; 176 | productName = DemoTests; 177 | productReference = 5E4E746F1A7C07A100F8C75F /* DemoTests.xctest */; 178 | productType = "com.apple.product-type.bundle.unit-test"; 179 | }; 180 | /* End PBXNativeTarget section */ 181 | 182 | /* Begin PBXProject section */ 183 | 5E4E74521A7C07A100F8C75F /* Project object */ = { 184 | isa = PBXProject; 185 | attributes = { 186 | LastUpgradeCheck = 0610; 187 | ORGANIZATIONNAME = "Ash Furrow"; 188 | TargetAttributes = { 189 | 5E4E74591A7C07A100F8C75F = { 190 | CreatedOnToolsVersion = 6.1.1; 191 | }; 192 | 5E4E746E1A7C07A100F8C75F = { 193 | CreatedOnToolsVersion = 6.1.1; 194 | TestTargetID = 5E4E74591A7C07A100F8C75F; 195 | }; 196 | }; 197 | }; 198 | buildConfigurationList = 5E4E74551A7C07A100F8C75F /* Build configuration list for PBXProject "Demo" */; 199 | compatibilityVersion = "Xcode 3.2"; 200 | developmentRegion = English; 201 | hasScannedForEncodings = 0; 202 | knownRegions = ( 203 | en, 204 | Base, 205 | ); 206 | mainGroup = 5E4E74511A7C07A100F8C75F; 207 | productRefGroup = 5E4E745B1A7C07A100F8C75F /* Products */; 208 | projectDirPath = ""; 209 | projectRoot = ""; 210 | targets = ( 211 | 5E4E74591A7C07A100F8C75F /* Demo */, 212 | 5E4E746E1A7C07A100F8C75F /* DemoTests */, 213 | ); 214 | }; 215 | /* End PBXProject section */ 216 | 217 | /* Begin PBXResourcesBuildPhase section */ 218 | 5E4E74581A7C07A100F8C75F /* Resources */ = { 219 | isa = PBXResourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | 5E4E74651A7C07A100F8C75F /* Main.storyboard in Resources */, 223 | 5E4E746A1A7C07A100F8C75F /* LaunchScreen.xib in Resources */, 224 | 5E4E74671A7C07A100F8C75F /* Images.xcassets in Resources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | 5E4E746D1A7C07A100F8C75F /* Resources */ = { 229 | isa = PBXResourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | /* End PBXResourcesBuildPhase section */ 236 | 237 | /* Begin PBXShellScriptBuildPhase section */ 238 | 27E9E65D44341397134E75A0 /* Copy Pods Resources */ = { 239 | isa = PBXShellScriptBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | ); 243 | inputPaths = ( 244 | ); 245 | name = "Copy Pods Resources"; 246 | outputPaths = ( 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | shellPath = /bin/sh; 250 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; 251 | showEnvVarsInLog = 0; 252 | }; 253 | 81A92F4445745454E45B6744 /* Check Pods Manifest.lock */ = { 254 | isa = PBXShellScriptBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | ); 258 | inputPaths = ( 259 | ); 260 | name = "Check Pods Manifest.lock"; 261 | outputPaths = ( 262 | ); 263 | runOnlyForDeploymentPostprocessing = 0; 264 | shellPath = /bin/sh; 265 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 266 | showEnvVarsInLog = 0; 267 | }; 268 | B941E360083BE98EE2079AF6 /* Embed Pods Frameworks */ = { 269 | isa = PBXShellScriptBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | ); 273 | inputPaths = ( 274 | ); 275 | name = "Embed Pods Frameworks"; 276 | outputPaths = ( 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | shellPath = /bin/sh; 280 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; 281 | showEnvVarsInLog = 0; 282 | }; 283 | /* End PBXShellScriptBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | 5E4E74561A7C07A100F8C75F /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 5E4E74621A7C07A100F8C75F /* ViewController.swift in Sources */, 291 | 5E4E74601A7C07A100F8C75F /* AppDelegate.swift in Sources */, 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | 5E4E746B1A7C07A100F8C75F /* Sources */ = { 296 | isa = PBXSourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | 5E4E74761A7C07A100F8C75F /* DemoTests.swift in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | /* End PBXSourcesBuildPhase section */ 304 | 305 | /* Begin PBXTargetDependency section */ 306 | 5E4E74711A7C07A100F8C75F /* PBXTargetDependency */ = { 307 | isa = PBXTargetDependency; 308 | target = 5E4E74591A7C07A100F8C75F /* Demo */; 309 | targetProxy = 5E4E74701A7C07A100F8C75F /* PBXContainerItemProxy */; 310 | }; 311 | /* End PBXTargetDependency section */ 312 | 313 | /* Begin PBXVariantGroup section */ 314 | 5E4E74631A7C07A100F8C75F /* Main.storyboard */ = { 315 | isa = PBXVariantGroup; 316 | children = ( 317 | 5E4E74641A7C07A100F8C75F /* Base */, 318 | ); 319 | name = Main.storyboard; 320 | sourceTree = ""; 321 | }; 322 | 5E4E74681A7C07A100F8C75F /* LaunchScreen.xib */ = { 323 | isa = PBXVariantGroup; 324 | children = ( 325 | 5E4E74691A7C07A100F8C75F /* Base */, 326 | ); 327 | name = LaunchScreen.xib; 328 | sourceTree = ""; 329 | }; 330 | /* End PBXVariantGroup section */ 331 | 332 | /* Begin XCBuildConfiguration section */ 333 | 5E4E74771A7C07A100F8C75F /* Debug */ = { 334 | isa = XCBuildConfiguration; 335 | buildSettings = { 336 | ALWAYS_SEARCH_USER_PATHS = NO; 337 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 338 | CLANG_CXX_LIBRARY = "libc++"; 339 | CLANG_ENABLE_MODULES = YES; 340 | CLANG_ENABLE_OBJC_ARC = YES; 341 | CLANG_WARN_BOOL_CONVERSION = YES; 342 | CLANG_WARN_CONSTANT_CONVERSION = YES; 343 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 344 | CLANG_WARN_EMPTY_BODY = YES; 345 | CLANG_WARN_ENUM_CONVERSION = YES; 346 | CLANG_WARN_INT_CONVERSION = YES; 347 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 348 | CLANG_WARN_UNREACHABLE_CODE = YES; 349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 350 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 351 | COPY_PHASE_STRIP = NO; 352 | ENABLE_STRICT_OBJC_MSGSEND = YES; 353 | GCC_C_LANGUAGE_STANDARD = gnu99; 354 | GCC_DYNAMIC_NO_PIC = NO; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 361 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 362 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 363 | GCC_WARN_UNDECLARED_SELECTOR = YES; 364 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 365 | GCC_WARN_UNUSED_FUNCTION = YES; 366 | GCC_WARN_UNUSED_VARIABLE = YES; 367 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 368 | MTL_ENABLE_DEBUG_INFO = YES; 369 | ONLY_ACTIVE_ARCH = YES; 370 | SDKROOT = iphoneos; 371 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 372 | }; 373 | name = Debug; 374 | }; 375 | 5E4E74781A7C07A100F8C75F /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_ENABLE_MODULES = YES; 382 | CLANG_ENABLE_OBJC_ARC = YES; 383 | CLANG_WARN_BOOL_CONVERSION = YES; 384 | CLANG_WARN_CONSTANT_CONVERSION = YES; 385 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 386 | CLANG_WARN_EMPTY_BODY = YES; 387 | CLANG_WARN_ENUM_CONVERSION = YES; 388 | CLANG_WARN_INT_CONVERSION = YES; 389 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 390 | CLANG_WARN_UNREACHABLE_CODE = YES; 391 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 392 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 393 | COPY_PHASE_STRIP = YES; 394 | ENABLE_NS_ASSERTIONS = NO; 395 | ENABLE_STRICT_OBJC_MSGSEND = YES; 396 | GCC_C_LANGUAGE_STANDARD = gnu99; 397 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 398 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 399 | GCC_WARN_UNDECLARED_SELECTOR = YES; 400 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 401 | GCC_WARN_UNUSED_FUNCTION = YES; 402 | GCC_WARN_UNUSED_VARIABLE = YES; 403 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 404 | MTL_ENABLE_DEBUG_INFO = NO; 405 | SDKROOT = iphoneos; 406 | VALIDATE_PRODUCT = YES; 407 | }; 408 | name = Release; 409 | }; 410 | 5E4E747A1A7C07A100F8C75F /* Debug */ = { 411 | isa = XCBuildConfiguration; 412 | baseConfigurationReference = F05DFE3F5147883D7B794D3F /* Pods.debug.xcconfig */; 413 | buildSettings = { 414 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 415 | INFOPLIST_FILE = Demo/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 417 | PRODUCT_NAME = "$(TARGET_NAME)"; 418 | }; 419 | name = Debug; 420 | }; 421 | 5E4E747B1A7C07A100F8C75F /* Release */ = { 422 | isa = XCBuildConfiguration; 423 | baseConfigurationReference = 6B90C7F7D8AC2DFF1C7E25B5 /* Pods.release.xcconfig */; 424 | buildSettings = { 425 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 426 | INFOPLIST_FILE = Demo/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | }; 430 | name = Release; 431 | }; 432 | 5E4E747D1A7C07A100F8C75F /* Debug */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | BUNDLE_LOADER = "$(TEST_HOST)"; 436 | FRAMEWORK_SEARCH_PATHS = ( 437 | "$(SDKROOT)/Developer/Library/Frameworks", 438 | "$(inherited)", 439 | ); 440 | GCC_PREPROCESSOR_DEFINITIONS = ( 441 | "DEBUG=1", 442 | "$(inherited)", 443 | ); 444 | INFOPLIST_FILE = DemoTests/Info.plist; 445 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 446 | PRODUCT_NAME = "$(TARGET_NAME)"; 447 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo.app/Demo"; 448 | }; 449 | name = Debug; 450 | }; 451 | 5E4E747E1A7C07A100F8C75F /* Release */ = { 452 | isa = XCBuildConfiguration; 453 | buildSettings = { 454 | BUNDLE_LOADER = "$(TEST_HOST)"; 455 | FRAMEWORK_SEARCH_PATHS = ( 456 | "$(SDKROOT)/Developer/Library/Frameworks", 457 | "$(inherited)", 458 | ); 459 | INFOPLIST_FILE = DemoTests/Info.plist; 460 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Demo.app/Demo"; 463 | }; 464 | name = Release; 465 | }; 466 | /* End XCBuildConfiguration section */ 467 | 468 | /* Begin XCConfigurationList section */ 469 | 5E4E74551A7C07A100F8C75F /* Build configuration list for PBXProject "Demo" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | 5E4E74771A7C07A100F8C75F /* Debug */, 473 | 5E4E74781A7C07A100F8C75F /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | 5E4E74791A7C07A100F8C75F /* Build configuration list for PBXNativeTarget "Demo" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | 5E4E747A1A7C07A100F8C75F /* Debug */, 482 | 5E4E747B1A7C07A100F8C75F /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | 5E4E747C1A7C07A100F8C75F /* Build configuration list for PBXNativeTarget "DemoTests" */ = { 488 | isa = XCConfigurationList; 489 | buildConfigurations = ( 490 | 5E4E747D1A7C07A100F8C75F /* Debug */, 491 | 5E4E747E1A7C07A100F8C75F /* Release */, 492 | ); 493 | defaultConfigurationIsVisible = 0; 494 | defaultConfigurationName = Release; 495 | }; 496 | /* End XCConfigurationList section */ 497 | }; 498 | rootObject = 5E4E74521A7C07A100F8C75F /* Project object */; 499 | } 500 | -------------------------------------------------------------------------------- /Demo/Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/Demo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Demo/Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by Ash Furrow on 2015-01-30. 6 | // Copyright (c) 2015 Ash Furrow. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Haste 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | 18 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 19 | 20 | NSTimer.scheduledTimerWithTimeInterval(1, block: { () -> () in 21 | println("Oh come on, mother. Not even my voicemail pranks are that elaborate – I wish they were. The current time is \(NSDate()) ") 22 | }, repeats: true) 23 | 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(application: UIApplication) { 28 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 29 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(application: UIApplication) { 33 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(application: UIApplication) { 38 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | func applicationDidBecomeActive(application: UIApplication) { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | func applicationWillTerminate(application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Demo/Demo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Demo/Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Demo/Demo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Demo/Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.ashfurrow.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Demo/Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by Ash Furrow on 2015-01-30. 6 | // Copyright (c) 2015 Ash Furrow. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Demo/DemoTests/DemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DemoTests.swift 3 | // DemoTests 4 | // 5 | // Created by Ash Furrow on 2015-01-30. 6 | // Copyright (c) 2015 Ash Furrow. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class DemoTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Demo/DemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.ashfurrow.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Demo/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | 3 | pod 'Haste', :path => '../' 4 | -------------------------------------------------------------------------------- /Demo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Haste (0.1) 3 | 4 | DEPENDENCIES: 5 | - Haste (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | Haste: 9 | :path: ../ 10 | 11 | SPEC CHECKSUMS: 12 | Haste: 96459425d55f65157bee89764f1b4c2ed9946cac 13 | 14 | COCOAPODS: 0.36.0.beta.2 15 | -------------------------------------------------------------------------------- /Haste.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Haste" 3 | s.version = "0.1" 4 | s.summary = "NSTimer Extension for Swift" 5 | 6 | s.description = <<-DESC 7 | Everyone has made NSTimer categories for `NSTimer` in Objective-C. 8 | But who has done it in Swift? Well, probably lots of people, 9 | but the point is that it is not as straightforward as you might think. 10 | DESC 11 | 12 | s.homepage = "https://github.com/ashfurrow/Haste" 13 | s.license = { :type => "MIT", :file => "LICENSE" } 14 | s.author = { "Ash Furrow" => "ash@ashfurrow.com" } 15 | s.social_media_url = "http://twitter.com/ashfurrow" 16 | s.platform = :ios, "8.0" 17 | s.source = { :git => "https://github.com/ashfurrow/Haste.git", :tag => s.version } 18 | s.source_files = "NSTimer+Haste.swift" 19 | s.framework = "Foundation" 20 | s.requires_arc = true 21 | end 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ash Furrow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /NSTimer+Haste.swift: -------------------------------------------------------------------------------- 1 | public extension NSTimer { 2 | typealias Block = () -> () 3 | 4 | private class BlockWrapper { 5 | let block: Block 6 | 7 | init(block: Block) { 8 | self.block = block 9 | } 10 | } 11 | 12 | public class func scheduledTimerWithTimeInterval(interval: NSTimeInterval, block: Block, repeats: Bool) -> NSTimer { 13 | return scheduledTimerWithTimeInterval(interval, target: self, selector: "_timerDidFire:", userInfo: BlockWrapper(block), repeats: repeats) 14 | } 15 | 16 | // This function can't be private, or else NSTimer can't access it. 17 | internal class func _timerDidFire(timer: NSTimer) { 18 | if let blockWrapper = timer.userInfo as? BlockWrapper { 19 | blockWrapper.block() 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Haste 2 | ================ 3 | 4 | Everyone has made block NSTimer categories for `NSTimer` in Objective-C. But who has done it in Swift? Well, probably lots of people, but the point is that it is not as straightforward as you might think. 5 | 6 | Usage 7 | ---------------- 8 | 9 | 1. Add `pod 'Haste'` to your Podfile. 10 | 2. Add `import Haste` whevever you want to time things with closures. 11 | 3. Call the following function. 12 | 13 | ```swift 14 | NSTimer.scheduledTimerWithTimeInterval(1, block: { () -> () in 15 | println("Why does anyone do the things they do?") 16 | }, repeats: true) 17 | 18 | ``` 19 | 20 | 4. That function returns the `NSTimer` instance, so you can call `invalidate()` on it when you want things to stop. 21 | --------------------------------------------------------------------------------