├── .gitignore ├── LICENSE ├── LevellingUp.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── LevellingUp ├── AVKitViewController.swift ├── ActionSheetViewController.swift ├── AlertsViewController.swift ├── AppComponents.swift ├── AppDelegate.swift ├── AsyncTestingViewController.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── BetterMovingAverage.swift ├── CoreLocationAuthorisationViewController.swift ├── HorseRaceController.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── in-app │ │ ├── grass.imageset │ │ ├── Contents.json │ │ └── grasswip1.png │ │ └── horse.imageset │ │ ├── Contents.json │ │ └── galloping-horse.png ├── Info.plist ├── MasterViewController.swift ├── MovingAverageProtocol.swift ├── NaiveMovingAverage.swift ├── NotificationActionsViewController.swift ├── NotificationAuthorisationViewController.swift ├── PopoverContentViewController.swift ├── PopoverViewController.swift ├── RotationViewController.swift └── countdown_new.mov ├── LevellingUpTests ├── AsyncTestingTests.swift ├── Info.plist ├── LevellingUpTests.swift └── MovingAverageTests.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 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LevellingUp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 220FF7E91AC5B5010031F2CF /* BetterMovingAverage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7E81AC5B5010031F2CF /* BetterMovingAverage.swift */; }; 11 | 220FF7EB1AC5B5120031F2CF /* MovingAverageProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7EA1AC5B5120031F2CF /* MovingAverageProtocol.swift */; }; 12 | 220FF7ED1AC5B5270031F2CF /* NaiveMovingAverage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7EC1AC5B5270031F2CF /* NaiveMovingAverage.swift */; }; 13 | 220FF7EF1AC5B55B0031F2CF /* MovingAverageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7EE1AC5B55B0031F2CF /* MovingAverageTests.swift */; }; 14 | 220FF7F21AC5CA1E0031F2CF /* AsyncTestingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7F11AC5CA1E0031F2CF /* AsyncTestingViewController.swift */; }; 15 | 220FF7F41AC5CA4C0031F2CF /* HorseRaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7F31AC5CA4C0031F2CF /* HorseRaceController.swift */; }; 16 | 220FF7F61AC5CB6E0031F2CF /* AsyncTestingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 220FF7F51AC5CB6E0031F2CF /* AsyncTestingTests.swift */; }; 17 | 223B118C1AC03A360070610A /* AVKitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 223B118B1AC03A360070610A /* AVKitViewController.swift */; }; 18 | 223B118F1AC06E9E0070610A /* countdown_new.mov in Resources */ = {isa = PBXBuildFile; fileRef = 223B118E1AC06E9E0070610A /* countdown_new.mov */; }; 19 | 2279CB841AB86E460009140F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CB831AB86E460009140F /* AppDelegate.swift */; }; 20 | 2279CB861AB86E460009140F /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CB851AB86E460009140F /* MasterViewController.swift */; }; 21 | 2279CB8B1AB86E460009140F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2279CB891AB86E460009140F /* Main.storyboard */; }; 22 | 2279CB8D1AB86E460009140F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2279CB8C1AB86E460009140F /* Images.xcassets */; }; 23 | 2279CB901AB86E460009140F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2279CB8E1AB86E460009140F /* LaunchScreen.xib */; }; 24 | 2279CB9C1AB86E460009140F /* LevellingUpTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CB9B1AB86E460009140F /* LevellingUpTests.swift */; }; 25 | 2279CBA71AB8CD3E0009140F /* AppComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBA61AB8CD3E0009140F /* AppComponents.swift */; }; 26 | 2279CBAA1AB9CE1F0009140F /* NotificationAuthorisationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBA91AB9CE1F0009140F /* NotificationAuthorisationViewController.swift */; }; 27 | 2279CBAC1ABA2F1A0009140F /* AlertsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBAB1ABA2F1A0009140F /* AlertsViewController.swift */; }; 28 | 2279CBAE1ABAC1CC0009140F /* PopoverViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBAD1ABAC1CC0009140F /* PopoverViewController.swift */; }; 29 | 2279CBB11ABAE5610009140F /* PopoverContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBB01ABAE5610009140F /* PopoverContentViewController.swift */; }; 30 | 2279CBB31ABB33B90009140F /* ActionSheetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBB21ABB33B90009140F /* ActionSheetViewController.swift */; }; 31 | 2279CBB51ABB70430009140F /* CoreLocationAuthorisationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2279CBB41ABB70430009140F /* CoreLocationAuthorisationViewController.swift */; }; 32 | 22AAFF8A1ABB7E9100D71DEA /* NotificationActionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22AAFF891ABB7E9100D71DEA /* NotificationActionsViewController.swift */; }; 33 | 22B45B751AC6D98300BDB4CC /* RotationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22B45B741AC6D98300BDB4CC /* RotationViewController.swift */; }; 34 | /* End PBXBuildFile section */ 35 | 36 | /* Begin PBXContainerItemProxy section */ 37 | 2279CB961AB86E460009140F /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = 2279CB761AB86E460009140F /* Project object */; 40 | proxyType = 1; 41 | remoteGlobalIDString = 2279CB7D1AB86E460009140F; 42 | remoteInfo = LevellingUp; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | 220FF7E81AC5B5010031F2CF /* BetterMovingAverage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BetterMovingAverage.swift; sourceTree = ""; }; 48 | 220FF7EA1AC5B5120031F2CF /* MovingAverageProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MovingAverageProtocol.swift; sourceTree = ""; }; 49 | 220FF7EC1AC5B5270031F2CF /* NaiveMovingAverage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NaiveMovingAverage.swift; sourceTree = ""; }; 50 | 220FF7EE1AC5B55B0031F2CF /* MovingAverageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MovingAverageTests.swift; sourceTree = ""; }; 51 | 220FF7F11AC5CA1E0031F2CF /* AsyncTestingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsyncTestingViewController.swift; sourceTree = ""; }; 52 | 220FF7F31AC5CA4C0031F2CF /* HorseRaceController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HorseRaceController.swift; sourceTree = ""; }; 53 | 220FF7F51AC5CB6E0031F2CF /* AsyncTestingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsyncTestingTests.swift; sourceTree = ""; }; 54 | 223B118B1AC03A360070610A /* AVKitViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AVKitViewController.swift; sourceTree = ""; }; 55 | 223B118E1AC06E9E0070610A /* countdown_new.mov */ = {isa = PBXFileReference; lastKnownFileType = video.quicktime; path = countdown_new.mov; sourceTree = ""; }; 56 | 2279CB7E1AB86E460009140F /* LevellingUp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LevellingUp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | 2279CB821AB86E460009140F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 2279CB831AB86E460009140F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 59 | 2279CB851AB86E460009140F /* MasterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = ""; }; 60 | 2279CB8A1AB86E460009140F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 61 | 2279CB8C1AB86E460009140F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 62 | 2279CB8F1AB86E460009140F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 63 | 2279CB951AB86E460009140F /* LevellingUpTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LevellingUpTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 2279CB9A1AB86E460009140F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65 | 2279CB9B1AB86E460009140F /* LevellingUpTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LevellingUpTests.swift; sourceTree = ""; }; 66 | 2279CBA61AB8CD3E0009140F /* AppComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppComponents.swift; sourceTree = ""; }; 67 | 2279CBA91AB9CE1F0009140F /* NotificationAuthorisationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationAuthorisationViewController.swift; sourceTree = ""; }; 68 | 2279CBAB1ABA2F1A0009140F /* AlertsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertsViewController.swift; sourceTree = ""; }; 69 | 2279CBAD1ABAC1CC0009140F /* PopoverViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverViewController.swift; sourceTree = ""; }; 70 | 2279CBB01ABAE5610009140F /* PopoverContentViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopoverContentViewController.swift; sourceTree = ""; }; 71 | 2279CBB21ABB33B90009140F /* ActionSheetViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheetViewController.swift; sourceTree = ""; }; 72 | 2279CBB41ABB70430009140F /* CoreLocationAuthorisationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreLocationAuthorisationViewController.swift; sourceTree = ""; }; 73 | 22AAFF891ABB7E9100D71DEA /* NotificationActionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationActionsViewController.swift; sourceTree = ""; }; 74 | 22B45B741AC6D98300BDB4CC /* RotationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotationViewController.swift; sourceTree = ""; }; 75 | /* End PBXFileReference section */ 76 | 77 | /* Begin PBXFrameworksBuildPhase section */ 78 | 2279CB7B1AB86E460009140F /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 2279CB921AB86E460009140F /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | 220FF7E11AC5B46D0031F2CF /* New Stuff */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 220FF7EE1AC5B55B0031F2CF /* MovingAverageTests.swift */, 99 | 220FF7F51AC5CB6E0031F2CF /* AsyncTestingTests.swift */, 100 | ); 101 | name = "New Stuff"; 102 | sourceTree = ""; 103 | }; 104 | 220FF7E71AC5B4F00031F2CF /* Test Performance */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 220FF7E81AC5B5010031F2CF /* BetterMovingAverage.swift */, 108 | 220FF7EA1AC5B5120031F2CF /* MovingAverageProtocol.swift */, 109 | 220FF7EC1AC5B5270031F2CF /* NaiveMovingAverage.swift */, 110 | ); 111 | name = "Test Performance"; 112 | sourceTree = ""; 113 | }; 114 | 223B118D1AC03ADE0070610A /* Aux */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 223B118E1AC06E9E0070610A /* countdown_new.mov */, 118 | 220FF7F31AC5CA4C0031F2CF /* HorseRaceController.swift */, 119 | ); 120 | name = Aux; 121 | sourceTree = ""; 122 | }; 123 | 2279CB751AB86E460009140F = { 124 | isa = PBXGroup; 125 | children = ( 126 | 2279CB801AB86E460009140F /* LevellingUp */, 127 | 2279CB981AB86E460009140F /* LevellingUpTests */, 128 | 2279CB7F1AB86E460009140F /* Products */, 129 | ); 130 | sourceTree = ""; 131 | }; 132 | 2279CB7F1AB86E460009140F /* Products */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 2279CB7E1AB86E460009140F /* LevellingUp.app */, 136 | 2279CB951AB86E460009140F /* LevellingUpTests.xctest */, 137 | ); 138 | name = Products; 139 | sourceTree = ""; 140 | }; 141 | 2279CB801AB86E460009140F /* LevellingUp */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 2279CBA81AB9CDF50009140F /* Fixes */, 145 | 22AAFF881ABB7E4400D71DEA /* New Stuff */, 146 | 2279CBA51AB8CD070009140F /* Data */, 147 | 2279CB831AB86E460009140F /* AppDelegate.swift */, 148 | 2279CB851AB86E460009140F /* MasterViewController.swift */, 149 | 2279CB891AB86E460009140F /* Main.storyboard */, 150 | 2279CB8C1AB86E460009140F /* Images.xcassets */, 151 | 2279CB8E1AB86E460009140F /* LaunchScreen.xib */, 152 | 2279CB811AB86E460009140F /* Supporting Files */, 153 | ); 154 | path = LevellingUp; 155 | sourceTree = ""; 156 | }; 157 | 2279CB811AB86E460009140F /* Supporting Files */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 2279CB821AB86E460009140F /* Info.plist */, 161 | ); 162 | name = "Supporting Files"; 163 | sourceTree = ""; 164 | }; 165 | 2279CB981AB86E460009140F /* LevellingUpTests */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 220FF7E11AC5B46D0031F2CF /* New Stuff */, 169 | 2279CB9B1AB86E460009140F /* LevellingUpTests.swift */, 170 | 2279CB991AB86E460009140F /* Supporting Files */, 171 | ); 172 | path = LevellingUpTests; 173 | sourceTree = ""; 174 | }; 175 | 2279CB991AB86E460009140F /* Supporting Files */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 2279CB9A1AB86E460009140F /* Info.plist */, 179 | ); 180 | name = "Supporting Files"; 181 | sourceTree = ""; 182 | }; 183 | 2279CBA51AB8CD070009140F /* Data */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | 2279CBA61AB8CD3E0009140F /* AppComponents.swift */, 187 | ); 188 | name = Data; 189 | sourceTree = ""; 190 | }; 191 | 2279CBA81AB9CDF50009140F /* Fixes */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | 2279CBAF1ABAE5520009140F /* Aux */, 195 | 2279CBA91AB9CE1F0009140F /* NotificationAuthorisationViewController.swift */, 196 | 2279CBAB1ABA2F1A0009140F /* AlertsViewController.swift */, 197 | 2279CBB21ABB33B90009140F /* ActionSheetViewController.swift */, 198 | 2279CBAD1ABAC1CC0009140F /* PopoverViewController.swift */, 199 | 2279CBB41ABB70430009140F /* CoreLocationAuthorisationViewController.swift */, 200 | ); 201 | name = Fixes; 202 | sourceTree = ""; 203 | }; 204 | 2279CBAF1ABAE5520009140F /* Aux */ = { 205 | isa = PBXGroup; 206 | children = ( 207 | 2279CBB01ABAE5610009140F /* PopoverContentViewController.swift */, 208 | ); 209 | name = Aux; 210 | sourceTree = ""; 211 | }; 212 | 22AAFF881ABB7E4400D71DEA /* New Stuff */ = { 213 | isa = PBXGroup; 214 | children = ( 215 | 223B118D1AC03ADE0070610A /* Aux */, 216 | 223B118B1AC03A360070610A /* AVKitViewController.swift */, 217 | 22B45B741AC6D98300BDB4CC /* RotationViewController.swift */, 218 | 22AAFF891ABB7E9100D71DEA /* NotificationActionsViewController.swift */, 219 | 220FF7F11AC5CA1E0031F2CF /* AsyncTestingViewController.swift */, 220 | 220FF7E71AC5B4F00031F2CF /* Test Performance */, 221 | ); 222 | name = "New Stuff"; 223 | sourceTree = ""; 224 | }; 225 | /* End PBXGroup section */ 226 | 227 | /* Begin PBXNativeTarget section */ 228 | 2279CB7D1AB86E460009140F /* LevellingUp */ = { 229 | isa = PBXNativeTarget; 230 | buildConfigurationList = 2279CB9F1AB86E460009140F /* Build configuration list for PBXNativeTarget "LevellingUp" */; 231 | buildPhases = ( 232 | 2279CB7A1AB86E460009140F /* Sources */, 233 | 2279CB7B1AB86E460009140F /* Frameworks */, 234 | 2279CB7C1AB86E460009140F /* Resources */, 235 | ); 236 | buildRules = ( 237 | ); 238 | dependencies = ( 239 | ); 240 | name = LevellingUp; 241 | productName = LevellingUp; 242 | productReference = 2279CB7E1AB86E460009140F /* LevellingUp.app */; 243 | productType = "com.apple.product-type.application"; 244 | }; 245 | 2279CB941AB86E460009140F /* LevellingUpTests */ = { 246 | isa = PBXNativeTarget; 247 | buildConfigurationList = 2279CBA21AB86E460009140F /* Build configuration list for PBXNativeTarget "LevellingUpTests" */; 248 | buildPhases = ( 249 | 2279CB911AB86E460009140F /* Sources */, 250 | 2279CB921AB86E460009140F /* Frameworks */, 251 | 2279CB931AB86E460009140F /* Resources */, 252 | ); 253 | buildRules = ( 254 | ); 255 | dependencies = ( 256 | 2279CB971AB86E460009140F /* PBXTargetDependency */, 257 | ); 258 | name = LevellingUpTests; 259 | productName = LevellingUpTests; 260 | productReference = 2279CB951AB86E460009140F /* LevellingUpTests.xctest */; 261 | productType = "com.apple.product-type.bundle.unit-test"; 262 | }; 263 | /* End PBXNativeTarget section */ 264 | 265 | /* Begin PBXProject section */ 266 | 2279CB761AB86E460009140F /* Project object */ = { 267 | isa = PBXProject; 268 | attributes = { 269 | LastUpgradeCheck = 0630; 270 | ORGANIZATIONNAME = shinobicontrols; 271 | TargetAttributes = { 272 | 2279CB7D1AB86E460009140F = { 273 | CreatedOnToolsVersion = 6.3; 274 | }; 275 | 2279CB941AB86E460009140F = { 276 | CreatedOnToolsVersion = 6.3; 277 | TestTargetID = 2279CB7D1AB86E460009140F; 278 | }; 279 | }; 280 | }; 281 | buildConfigurationList = 2279CB791AB86E460009140F /* Build configuration list for PBXProject "LevellingUp" */; 282 | compatibilityVersion = "Xcode 3.2"; 283 | developmentRegion = English; 284 | hasScannedForEncodings = 0; 285 | knownRegions = ( 286 | en, 287 | Base, 288 | ); 289 | mainGroup = 2279CB751AB86E460009140F; 290 | productRefGroup = 2279CB7F1AB86E460009140F /* Products */; 291 | projectDirPath = ""; 292 | projectRoot = ""; 293 | targets = ( 294 | 2279CB7D1AB86E460009140F /* LevellingUp */, 295 | 2279CB941AB86E460009140F /* LevellingUpTests */, 296 | ); 297 | }; 298 | /* End PBXProject section */ 299 | 300 | /* Begin PBXResourcesBuildPhase section */ 301 | 2279CB7C1AB86E460009140F /* Resources */ = { 302 | isa = PBXResourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | 2279CB8B1AB86E460009140F /* Main.storyboard in Resources */, 306 | 2279CB901AB86E460009140F /* LaunchScreen.xib in Resources */, 307 | 2279CB8D1AB86E460009140F /* Images.xcassets in Resources */, 308 | 223B118F1AC06E9E0070610A /* countdown_new.mov in Resources */, 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | 2279CB931AB86E460009140F /* Resources */ = { 313 | isa = PBXResourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | /* End PBXResourcesBuildPhase section */ 320 | 321 | /* Begin PBXSourcesBuildPhase section */ 322 | 2279CB7A1AB86E460009140F /* Sources */ = { 323 | isa = PBXSourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | 220FF7EB1AC5B5120031F2CF /* MovingAverageProtocol.swift in Sources */, 327 | 2279CBB31ABB33B90009140F /* ActionSheetViewController.swift in Sources */, 328 | 2279CBAA1AB9CE1F0009140F /* NotificationAuthorisationViewController.swift in Sources */, 329 | 220FF7ED1AC5B5270031F2CF /* NaiveMovingAverage.swift in Sources */, 330 | 22B45B751AC6D98300BDB4CC /* RotationViewController.swift in Sources */, 331 | 220FF7F41AC5CA4C0031F2CF /* HorseRaceController.swift in Sources */, 332 | 2279CBA71AB8CD3E0009140F /* AppComponents.swift in Sources */, 333 | 2279CBB11ABAE5610009140F /* PopoverContentViewController.swift in Sources */, 334 | 220FF7F21AC5CA1E0031F2CF /* AsyncTestingViewController.swift in Sources */, 335 | 2279CBAC1ABA2F1A0009140F /* AlertsViewController.swift in Sources */, 336 | 2279CB861AB86E460009140F /* MasterViewController.swift in Sources */, 337 | 2279CBB51ABB70430009140F /* CoreLocationAuthorisationViewController.swift in Sources */, 338 | 2279CBAE1ABAC1CC0009140F /* PopoverViewController.swift in Sources */, 339 | 223B118C1AC03A360070610A /* AVKitViewController.swift in Sources */, 340 | 220FF7E91AC5B5010031F2CF /* BetterMovingAverage.swift in Sources */, 341 | 2279CB841AB86E460009140F /* AppDelegate.swift in Sources */, 342 | 22AAFF8A1ABB7E9100D71DEA /* NotificationActionsViewController.swift in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | 2279CB911AB86E460009140F /* Sources */ = { 347 | isa = PBXSourcesBuildPhase; 348 | buildActionMask = 2147483647; 349 | files = ( 350 | 2279CB9C1AB86E460009140F /* LevellingUpTests.swift in Sources */, 351 | 220FF7EF1AC5B55B0031F2CF /* MovingAverageTests.swift in Sources */, 352 | 220FF7F61AC5CB6E0031F2CF /* AsyncTestingTests.swift in Sources */, 353 | ); 354 | runOnlyForDeploymentPostprocessing = 0; 355 | }; 356 | /* End PBXSourcesBuildPhase section */ 357 | 358 | /* Begin PBXTargetDependency section */ 359 | 2279CB971AB86E460009140F /* PBXTargetDependency */ = { 360 | isa = PBXTargetDependency; 361 | target = 2279CB7D1AB86E460009140F /* LevellingUp */; 362 | targetProxy = 2279CB961AB86E460009140F /* PBXContainerItemProxy */; 363 | }; 364 | /* End PBXTargetDependency section */ 365 | 366 | /* Begin PBXVariantGroup section */ 367 | 2279CB891AB86E460009140F /* Main.storyboard */ = { 368 | isa = PBXVariantGroup; 369 | children = ( 370 | 2279CB8A1AB86E460009140F /* Base */, 371 | ); 372 | name = Main.storyboard; 373 | sourceTree = ""; 374 | }; 375 | 2279CB8E1AB86E460009140F /* LaunchScreen.xib */ = { 376 | isa = PBXVariantGroup; 377 | children = ( 378 | 2279CB8F1AB86E460009140F /* Base */, 379 | ); 380 | name = LaunchScreen.xib; 381 | sourceTree = ""; 382 | }; 383 | /* End PBXVariantGroup section */ 384 | 385 | /* Begin XCBuildConfiguration section */ 386 | 2279CB9D1AB86E460009140F /* Debug */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ALWAYS_SEARCH_USER_PATHS = NO; 390 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 391 | CLANG_CXX_LIBRARY = "libc++"; 392 | CLANG_ENABLE_MODULES = YES; 393 | CLANG_ENABLE_OBJC_ARC = YES; 394 | CLANG_WARN_BOOL_CONVERSION = YES; 395 | CLANG_WARN_CONSTANT_CONVERSION = YES; 396 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 397 | CLANG_WARN_EMPTY_BODY = YES; 398 | CLANG_WARN_ENUM_CONVERSION = YES; 399 | CLANG_WARN_INT_CONVERSION = YES; 400 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 401 | CLANG_WARN_UNREACHABLE_CODE = YES; 402 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 403 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 404 | COPY_PHASE_STRIP = NO; 405 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 406 | ENABLE_STRICT_OBJC_MSGSEND = YES; 407 | GCC_C_LANGUAGE_STANDARD = gnu99; 408 | GCC_DYNAMIC_NO_PIC = NO; 409 | GCC_NO_COMMON_BLOCKS = YES; 410 | GCC_OPTIMIZATION_LEVEL = 0; 411 | GCC_PREPROCESSOR_DEFINITIONS = ( 412 | "DEBUG=1", 413 | "$(inherited)", 414 | ); 415 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 418 | GCC_WARN_UNDECLARED_SELECTOR = YES; 419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 | GCC_WARN_UNUSED_FUNCTION = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 423 | MTL_ENABLE_DEBUG_INFO = YES; 424 | ONLY_ACTIVE_ARCH = YES; 425 | SDKROOT = iphoneos; 426 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 427 | TARGETED_DEVICE_FAMILY = "1,2"; 428 | }; 429 | name = Debug; 430 | }; 431 | 2279CB9E1AB86E460009140F /* Release */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | ALWAYS_SEARCH_USER_PATHS = NO; 435 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 436 | CLANG_CXX_LIBRARY = "libc++"; 437 | CLANG_ENABLE_MODULES = YES; 438 | CLANG_ENABLE_OBJC_ARC = YES; 439 | CLANG_WARN_BOOL_CONVERSION = YES; 440 | CLANG_WARN_CONSTANT_CONVERSION = YES; 441 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 442 | CLANG_WARN_EMPTY_BODY = YES; 443 | CLANG_WARN_ENUM_CONVERSION = YES; 444 | CLANG_WARN_INT_CONVERSION = YES; 445 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 446 | CLANG_WARN_UNREACHABLE_CODE = YES; 447 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 448 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 449 | COPY_PHASE_STRIP = NO; 450 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 451 | ENABLE_NS_ASSERTIONS = NO; 452 | ENABLE_STRICT_OBJC_MSGSEND = YES; 453 | GCC_C_LANGUAGE_STANDARD = gnu99; 454 | GCC_NO_COMMON_BLOCKS = YES; 455 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 456 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 457 | GCC_WARN_UNDECLARED_SELECTOR = YES; 458 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 459 | GCC_WARN_UNUSED_FUNCTION = YES; 460 | GCC_WARN_UNUSED_VARIABLE = YES; 461 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 462 | MTL_ENABLE_DEBUG_INFO = NO; 463 | SDKROOT = iphoneos; 464 | TARGETED_DEVICE_FAMILY = "1,2"; 465 | VALIDATE_PRODUCT = YES; 466 | }; 467 | name = Release; 468 | }; 469 | 2279CBA01AB86E460009140F /* Debug */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 473 | INFOPLIST_FILE = LevellingUp/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | }; 477 | name = Debug; 478 | }; 479 | 2279CBA11AB86E460009140F /* Release */ = { 480 | isa = XCBuildConfiguration; 481 | buildSettings = { 482 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 483 | INFOPLIST_FILE = LevellingUp/Info.plist; 484 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | }; 487 | name = Release; 488 | }; 489 | 2279CBA31AB86E460009140F /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | BUNDLE_LOADER = "$(TEST_HOST)"; 493 | FRAMEWORK_SEARCH_PATHS = ( 494 | "$(SDKROOT)/Developer/Library/Frameworks", 495 | "$(inherited)", 496 | ); 497 | GCC_PREPROCESSOR_DEFINITIONS = ( 498 | "DEBUG=1", 499 | "$(inherited)", 500 | ); 501 | INFOPLIST_FILE = LevellingUpTests/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 503 | PRODUCT_NAME = "$(TARGET_NAME)"; 504 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LevellingUp.app/LevellingUp"; 505 | }; 506 | name = Debug; 507 | }; 508 | 2279CBA41AB86E460009140F /* Release */ = { 509 | isa = XCBuildConfiguration; 510 | buildSettings = { 511 | BUNDLE_LOADER = "$(TEST_HOST)"; 512 | FRAMEWORK_SEARCH_PATHS = ( 513 | "$(SDKROOT)/Developer/Library/Frameworks", 514 | "$(inherited)", 515 | ); 516 | INFOPLIST_FILE = LevellingUpTests/Info.plist; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LevellingUp.app/LevellingUp"; 520 | }; 521 | name = Release; 522 | }; 523 | /* End XCBuildConfiguration section */ 524 | 525 | /* Begin XCConfigurationList section */ 526 | 2279CB791AB86E460009140F /* Build configuration list for PBXProject "LevellingUp" */ = { 527 | isa = XCConfigurationList; 528 | buildConfigurations = ( 529 | 2279CB9D1AB86E460009140F /* Debug */, 530 | 2279CB9E1AB86E460009140F /* Release */, 531 | ); 532 | defaultConfigurationIsVisible = 0; 533 | defaultConfigurationName = Release; 534 | }; 535 | 2279CB9F1AB86E460009140F /* Build configuration list for PBXNativeTarget "LevellingUp" */ = { 536 | isa = XCConfigurationList; 537 | buildConfigurations = ( 538 | 2279CBA01AB86E460009140F /* Debug */, 539 | 2279CBA11AB86E460009140F /* Release */, 540 | ); 541 | defaultConfigurationIsVisible = 0; 542 | defaultConfigurationName = Release; 543 | }; 544 | 2279CBA21AB86E460009140F /* Build configuration list for PBXNativeTarget "LevellingUpTests" */ = { 545 | isa = XCConfigurationList; 546 | buildConfigurations = ( 547 | 2279CBA31AB86E460009140F /* Debug */, 548 | 2279CBA41AB86E460009140F /* Release */, 549 | ); 550 | defaultConfigurationIsVisible = 0; 551 | defaultConfigurationName = Release; 552 | }; 553 | /* End XCConfigurationList section */ 554 | }; 555 | rootObject = 2279CB761AB86E460009140F /* Project object */; 556 | } 557 | -------------------------------------------------------------------------------- /LevellingUp.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LevellingUp/AVKitViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | import AVKit 19 | import AVFoundation 20 | 21 | class AVKitViewController: AVPlayerViewController { 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | // Do any additional setup after loading the view. 27 | 28 | let url = NSBundle.mainBundle().URLForResource("countdown_new", withExtension: "mov") 29 | player = AVPlayer(URL: url) 30 | 31 | // Some configuration 32 | showsPlaybackControls = true 33 | 34 | // AVFoundation pipeline controls 35 | player.play() 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /LevellingUp/ActionSheetViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | class ActionSheetViewController: UIViewController { 20 | 21 | @IBAction func handleActionSheetPressed(sender: UIView) { 22 | let actionSheet = UIAlertController(title: "Action Sheet", message: "Using the alert controller", preferredStyle: .ActionSheet) 23 | if let presentationController = actionSheet.popoverPresentationController { 24 | presentationController.sourceView = sender 25 | presentationController.sourceRect = sender.bounds 26 | } 27 | 28 | let dismissHandler = { 29 | (action: UIAlertAction!) in 30 | self.dismissViewControllerAnimated(true, completion: nil) 31 | } 32 | actionSheet.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: dismissHandler)) 33 | actionSheet.addAction(UIAlertAction(title: "Delete", style: .Destructive, handler: dismissHandler)) 34 | actionSheet.addAction(UIAlertAction(title: "OK", style: .Default, handler: dismissHandler)) 35 | presentViewController(actionSheet, animated: true, completion: nil) 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /LevellingUp/AlertsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | 18 | import UIKit 19 | 20 | class AlertsViewController: UIViewController { 21 | 22 | @IBAction func handleAlertMePressed(sender: AnyObject) { 23 | let alert = UIAlertController(title: "Alert", 24 | message: "Using the alert controller", 25 | preferredStyle: .Alert) 26 | 27 | let dismissHandler = { 28 | (action: UIAlertAction!) in 29 | self.dismissViewControllerAnimated(true, completion: nil) 30 | } 31 | 32 | alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: dismissHandler)) 33 | alert.addAction(UIAlertAction(title: "Delete", style: .Destructive, handler: dismissHandler)) 34 | alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: dismissHandler)) 35 | alert.addTextFieldWithConfigurationHandler { textField in 36 | textField.placeholder = "Sample text field" 37 | } 38 | presentViewController(alert, animated: true, completion: nil) 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /LevellingUp/AppComponents.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | enum AppComponentCategory: String { 20 | case Fix = "Breaking Changes" 21 | case NewFeature = "New Features" 22 | 23 | static let allValues = [ Fix, NewFeature ] 24 | } 25 | 26 | enum AppComponentType { 27 | case Storyboard(String) 28 | case Code((UIStoryboard?) -> UIViewController?) 29 | } 30 | 31 | struct AppComponent { 32 | let name: String 33 | let category: AppComponentCategory 34 | let type: AppComponentType 35 | 36 | init(name: String, category: AppComponentCategory, type: AppComponentType) { 37 | self.name = name 38 | self.category = category 39 | self.type = type 40 | } 41 | 42 | init(name: String, category: AppComponentCategory, vcIdentifier: String) { 43 | let type = AppComponentType.Storyboard(vcIdentifier) 44 | self.init(name: name, category: category, type: type) 45 | } 46 | 47 | init(name: String, category: AppComponentCategory, vcInstantiation: (UIStoryboard?) -> UIViewController?) { 48 | let type = AppComponentType.Code(vcInstantiation) 49 | self.init(name: name, category: category, type: type) 50 | } 51 | } 52 | 53 | extension AppComponent { 54 | static func appStructure() -> [AppComponent] { 55 | return [ 56 | AppComponent(name: "Notification Authorisation", category: .Fix, vcIdentifier: "NotificationAuthorisationVC"), 57 | AppComponent(name: "Alert View", category: .Fix, vcIdentifier: "AlertsViewVC"), 58 | AppComponent(name: "ActionSheet", category: .Fix, vcIdentifier: "ActionSheetVC"), 59 | AppComponent(name: "Popovers", category: .Fix, vcIdentifier: "PopoverVC"), 60 | AppComponent(name: "CoreLocation Authorisation", category: .Fix, vcIdentifier: "LocationAuthorisationVC"), 61 | AppComponent(name: "Link to Settings", category: .NewFeature, vcIdentifier: "NotificationAuthorisationVC"), 62 | AppComponent(name: "AVKit", category: .NewFeature, vcIdentifier: "AVKitVC"), 63 | AppComponent(name: "Notification Actions", category: .NewFeature, vcIdentifier: "NotificationActionsVC"), 64 | AppComponent(name: "Rotation", category: .NewFeature, vcIdentifier: "RotationVC"), 65 | AppComponent(name: "Async Testing", category: .NewFeature, vcIdentifier: "AsyncTestingVC") 66 | ] 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /LevellingUp/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | let userNotificationSettingsKey = "UserNotificationSettingsDidChange" 18 | let localNotificationFiredKey = "LocalNotificationFired" 19 | let localNotificationTriggeredActionKey = "LocalNotificationTriggeredAction" 20 | 21 | 22 | import UIKit 23 | 24 | @UIApplicationMain 25 | class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate { 26 | 27 | var window: UIWindow? 28 | 29 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 30 | // Override point for customization after application launch. 31 | let splitViewController = self.window!.rootViewController as! UISplitViewController 32 | splitViewController.delegate = self 33 | return true 34 | } 35 | 36 | 37 | // MARK: - Notification Settings 38 | func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) { 39 | NSNotificationCenter.defaultCenter().postNotificationName(userNotificationSettingsKey, object: self) 40 | } 41 | 42 | // MARK: - Local notification fired 43 | func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) { 44 | NSNotificationCenter.defaultCenter().postNotificationName(localNotificationFiredKey, object: self, userInfo: ["notification": notification]) 45 | } 46 | 47 | // MARK: - Action handling 48 | func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void) { 49 | if let identifier = identifier { 50 | let info = ["notification" : notification, "identifier" : identifier] 51 | NSNotificationCenter.defaultCenter().postNotificationName(localNotificationTriggeredActionKey, object: self, userInfo: info) 52 | } 53 | completionHandler() 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /LevellingUp/AsyncTestingViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | public class AsyncTestingViewController: UIViewController { 20 | 21 | @IBOutlet public weak var horse1: UIImageView! 22 | @IBOutlet public weak var horse2: UIImageView! 23 | @IBOutlet weak var horse1StartConstraint: NSLayoutConstraint! 24 | @IBOutlet weak var horse2StartConstraint: NSLayoutConstraint! 25 | 26 | @IBOutlet public weak var startRaceButton: UIButton! 27 | @IBOutlet public weak var resetButton: UIButton! 28 | 29 | public var raceController: TwoHorseRaceController! 30 | private var numberOfHorsesCurrentlyRunning = 0 31 | 32 | 33 | override public func viewDidLoad() { 34 | super.viewDidLoad() 35 | // Do any additional setup after loading the view, typically from a nib. 36 | raceController = createRaceController() 37 | resetButton.enabled = false 38 | 39 | } 40 | 41 | @IBAction public func handleStartRaceButton(sender: UIButton) { 42 | numberOfHorsesCurrentlyRunning = 2 43 | startRaceButton.enabled = false 44 | raceController.startRace(5, horseCrossedLineCallback:{ 45 | (horse:Horse) in 46 | // Deal with the number of horses 47 | self.numberOfHorsesCurrentlyRunning -= 1 48 | if self.numberOfHorsesCurrentlyRunning == 0 { 49 | self.resetButton.enabled = true 50 | } 51 | 52 | switch horse.horseView { 53 | case self.horse1: 54 | println("Horse 1 has completed the race!") 55 | case self.horse2: 56 | println("Horse 2 has completed the race!") 57 | default: 58 | println("That horse wasn't in the race") 59 | } 60 | }) 61 | } 62 | 63 | @IBAction func handleResetRaceButton(sender: UIButton) { 64 | raceController.reset() 65 | startRaceButton.enabled = true 66 | resetButton.enabled = false 67 | } 68 | 69 | 70 | // Utility methods 71 | func createRaceController() -> TwoHorseRaceController { 72 | let h1 = Horse(horseView: horse1, startConstraint: horse1StartConstraint, finishLineOffset: 0) 73 | let h2 = Horse(horseView: horse2, startConstraint: horse2StartConstraint, finishLineOffset: 0) 74 | 75 | return TwoHorseRaceController(horses: [h1, h2]) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /LevellingUp/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 | -------------------------------------------------------------------------------- /LevellingUp/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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 60 | 67 | 74 | 81 | 92 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 167 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 251 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 295 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 338 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 421 | 431 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 523 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 595 | 601 | 607 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | -------------------------------------------------------------------------------- /LevellingUp/BetterMovingAverage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import Foundation 18 | 19 | public class BetterMovingAverageCalculator: MovingAverageCalculator { 20 | 21 | public var windowSize: Int 22 | 23 | public init() { 24 | windowSize = 1 25 | } 26 | 27 | public func calculateMovingAverage(data: [Double]) -> [Double] { 28 | var result = [Double]() 29 | 30 | // Bail out if we don't have enough data 31 | if(data.count < windowSize) { 32 | return result 33 | } 34 | 35 | var currentSum = data[0.. MKOverlayRenderer! { 58 | if let overlay = overlay as? MKPolyline { 59 | let renderer = MKPolylineRenderer(polyline: overlay) 60 | renderer.lineWidth = 4.0 61 | renderer.strokeColor = UIColor.blueColor().colorWithAlphaComponent(0.7) 62 | return renderer 63 | } 64 | return nil 65 | } 66 | 67 | 68 | // MARK:- Utility Methods 69 | private func updateMapWithPoints(points: [CLLocationCoordinate2D]) { 70 | let oldTrack = routeTrack 71 | 72 | // This has to be mutable, so we make a new reference 73 | var coordinates = points 74 | 75 | // Create the new route track 76 | routeTrack = MKPolyline(coordinates: &coordinates, count: points.count) 77 | 78 | // Switch them out 79 | mapView.addOverlay(routeTrack) 80 | mapView.removeOverlay(oldTrack) 81 | 82 | // Zoom the map 83 | mapView.visibleMapRect = mapView.mapRectThatFits(routeTrack.boundingMapRect, edgePadding: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)) 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /LevellingUp/HorseRaceController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import Foundation 18 | import UIKit 19 | 20 | public struct Horse { 21 | public var horseView: UIView 22 | var startConstraint: NSLayoutConstraint 23 | var finishConstraint: NSLayoutConstraint? 24 | 25 | init(horseView: UIView, startConstraint: NSLayoutConstraint, finishLineOffset:CGFloat) { 26 | self.horseView = horseView 27 | self.startConstraint = startConstraint 28 | self.finishConstraint = NSLayoutConstraint(item: horseView, attribute: .Right, relatedBy: .Equal, toItem: horseView.superview, attribute: .Right, multiplier: 1, constant: finishLineOffset) 29 | } 30 | } 31 | 32 | 33 | public class TwoHorseRaceController { 34 | 35 | var horses: [Horse] 36 | 37 | init(horses: [Horse]) { 38 | self.horses = horses 39 | srand48(time(nil)); 40 | } 41 | 42 | public func reset() { 43 | for horse in horses { 44 | updateContraintsToStartOfRace(horse) 45 | horse.horseView.layoutIfNeeded() 46 | } 47 | } 48 | 49 | public func startRace(maxDuration: NSTimeInterval, horseCrossedLineCallback: ((Horse) -> Void)?) { 50 | 51 | for horse in horses { 52 | // Generate a random time 53 | let duration = maxDuration / 2.0 * (1 + drand48()) 54 | 55 | // Perform the animation 56 | UIView.animateWithDuration(duration, delay: 0, options: .CurveEaseIn, 57 | animations: { 58 | self.updateConstraintsToEndOfRace(horse) 59 | horse.horseView.layoutIfNeeded() 60 | }, completion: { _ in 61 | if let callback = horseCrossedLineCallback { 62 | callback(horse) 63 | } 64 | }) 65 | } 66 | } 67 | 68 | func updateConstraintsToEndOfRace(horse: Horse) { 69 | horse.startConstraint.active = false 70 | horse.finishConstraint?.active = true 71 | } 72 | 73 | func updateContraintsToStartOfRace(horse: Horse) { 74 | horse.finishConstraint?.active = false 75 | horse.startConstraint.active = true 76 | } 77 | 78 | 79 | public func someKindOfAsyncMethod(completionHandler: () -> ()) { 80 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { 81 | sleep(3) 82 | dispatch_async(dispatch_get_main_queue(), { 83 | completionHandler()}) 84 | }) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /LevellingUp/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /LevellingUp/Images.xcassets/in-app/grass.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "grasswip1.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /LevellingUp/Images.xcassets/in-app/grass.imageset/grasswip1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLogic/iOS8-LevellingUp/96c831666837773d21d70b97fd282d8cd5cd8624/LevellingUp/Images.xcassets/in-app/grass.imageset/grasswip1.png -------------------------------------------------------------------------------- /LevellingUp/Images.xcassets/in-app/horse.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "galloping-horse.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /LevellingUp/Images.xcassets/in-app/horse.imageset/galloping-horse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLogic/iOS8-LevellingUp/96c831666837773d21d70b97fd282d8cd5cd8624/LevellingUp/Images.xcassets/in-app/horse.imageset/galloping-horse.png -------------------------------------------------------------------------------- /LevellingUp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.shinobicontrols.$(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 | NSLocationUsageDescription 26 | Please let me use your location 27 | NSLocationWhenInUseUsageDescription 28 | I would love for you to click "Allow" 29 | UILaunchStoryboardName 30 | LaunchScreen 31 | UIMainStoryboardFile 32 | Main 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UIStatusBarTintParameters 38 | 39 | UINavigationBar 40 | 41 | Style 42 | UIBarStyleDefault 43 | Translucent 44 | 45 | 46 | 47 | UISupportedInterfaceOrientations 48 | 49 | UIInterfaceOrientationPortrait 50 | UIInterfaceOrientationLandscapeLeft 51 | UIInterfaceOrientationLandscapeRight 52 | 53 | UISupportedInterfaceOrientations~ipad 54 | 55 | UIInterfaceOrientationPortrait 56 | UIInterfaceOrientationPortraitUpsideDown 57 | UIInterfaceOrientationLandscapeLeft 58 | UIInterfaceOrientationLandscapeRight 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /LevellingUp/MasterViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | 18 | import UIKit 19 | 20 | class MasterViewController: UITableViewController { 21 | 22 | let appStructure = AppComponent.appStructure() 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | // Do any additional setup after loading the view, typically from a nib. 27 | } 28 | 29 | // MARK: - Row Selection 30 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 31 | let component = componentsForCategoryIndex(indexPath.section)[indexPath.row] 32 | var newVC: UIViewController? 33 | 34 | switch component.type { 35 | case .Storyboard(let vcIdentifier): 36 | newVC = storyboard?.instantiateViewControllerWithIdentifier(vcIdentifier) as? UIViewController 37 | case .Code(let instantiation): 38 | newVC = instantiation(storyboard) 39 | } 40 | 41 | if let newVC = newVC { 42 | showDetailViewController(newVC, sender: self) 43 | } 44 | } 45 | 46 | // MARK: - Table View 47 | override func numberOfSectionsInTableView(tableView: UITableView) -> Int { 48 | return AppComponentCategory.allValues.count 49 | } 50 | 51 | override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 52 | return AppComponentCategory.allValues[section].rawValue 53 | } 54 | 55 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 56 | return componentsForCategoryIndex(section).count 57 | } 58 | 59 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 60 | let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell 61 | 62 | let component = componentsForCategoryIndex(indexPath.section)[indexPath.row] 63 | cell.textLabel!.text = component.name 64 | return cell 65 | } 66 | 67 | // MARK: - Utilities 68 | private func componentsForCategoryIndex(index: Int) -> [AppComponent] { 69 | let category = AppComponentCategory.allValues[index] 70 | return componentsForCategory(category) 71 | } 72 | 73 | private func componentsForCategory(category: AppComponentCategory) -> [AppComponent] { 74 | return appStructure.filter({ $0.category == category }) 75 | } 76 | 77 | } 78 | 79 | -------------------------------------------------------------------------------- /LevellingUp/MovingAverageProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import Foundation 18 | 19 | public protocol MovingAverageCalculator { 20 | // The length of the window 21 | var windowSize: Int { get set } 22 | 23 | // Calculate the moving average on for the given data set 24 | func calculateMovingAverage(data: [Double]) -> [Double] 25 | } -------------------------------------------------------------------------------- /LevellingUp/NaiveMovingAverage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import Foundation 18 | 19 | public class NaiveMovingAverageCalculator: MovingAverageCalculator { 20 | 21 | public var windowSize: Int 22 | 23 | public init() { 24 | windowSize = 1 25 | } 26 | 27 | public func calculateMovingAverage(data: [Double]) -> [Double] { 28 | // Create an array to store the result 29 | var result = [Double]() 30 | 31 | if(data.count < windowSize) { 32 | return result 33 | } 34 | 35 | // Now perform the calculation 36 | for i in 0...(data.count - windowSize) { 37 | let slice = data[i..<(i+windowSize)] 38 | let partialSum = slice.reduce(0) { $0 + $1 } 39 | result.append(Double(partialSum) / Double(windowSize)) 40 | } 41 | 42 | return result 43 | } 44 | } -------------------------------------------------------------------------------- /LevellingUp/NotificationActionsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | class NotificationActionsViewController: UIViewController { 20 | 21 | let notificationActionDemoString = "AskMeNotificationString" 22 | let cancelNotificationString = "CancelNotificationString" 23 | let askAgainNotificationString = "AskAgainNotificationString" 24 | 25 | @IBOutlet weak var lastAskedLabel: UILabel! 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | // Request authorisation for local notifications 31 | let requestedTypes = UIUserNotificationType.Alert 32 | let category = prepareNotificationCategory() 33 | let settingsRequest = UIUserNotificationSettings(forTypes: requestedTypes, categories: [category]) 34 | UIApplication.sharedApplication().registerUserNotificationSettings(settingsRequest) 35 | 36 | // Handle local notifications being fired 37 | NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleLocalNotificationReceived:", name: localNotificationFiredKey, object: nil) 38 | NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleNotificationAction:", name: localNotificationTriggeredActionKey, object: nil) 39 | } 40 | 41 | deinit { 42 | NSNotificationCenter.defaultCenter().removeObserver(self) 43 | } 44 | 45 | @IBAction func handleAskMeLaterPressed(sender: AnyObject) { 46 | // Cancel any existing notifications 47 | UIApplication.sharedApplication().cancelAllLocalNotifications() 48 | 49 | // Create a new notification 50 | let notification = UILocalNotification() 51 | notification.fireDate = NSDate(timeIntervalSinceNow: 3) 52 | notification.alertBody = "Asking you now" 53 | notification.category = notificationActionDemoString 54 | 55 | // Schedule Notification 56 | UIApplication.sharedApplication().scheduleLocalNotification(notification) 57 | } 58 | 59 | 60 | // Notification handling 61 | func handleLocalNotificationReceived(notification: NSNotification) { 62 | lastAskedLabel.text = "You Answered!" 63 | } 64 | 65 | // Action handling 66 | func handleNotificationAction(notification: NSNotification) { 67 | if let userInfo = notification.userInfo, 68 | let identifier = userInfo["identifier"] as? String { 69 | switch identifier { 70 | case cancelNotificationString: 71 | lastAskedLabel.text = "You cancelled" 72 | case askAgainNotificationString: 73 | lastAskedLabel.text = "You restarted!" 74 | handleAskMeLaterPressed(lastAskedLabel) 75 | default: 76 | break 77 | } 78 | } 79 | } 80 | 81 | 82 | // MARK:- Utiltiies 83 | private func prepareNotificationCategory() -> UIUserNotificationCategory { 84 | let cancelAction = UIMutableUserNotificationAction() 85 | cancelAction.identifier = cancelNotificationString 86 | cancelAction.destructive = true 87 | cancelAction.title = "Cancel" 88 | // Should the app be started in the foreground to handle the request? 89 | cancelAction.activationMode = .Background 90 | cancelAction.authenticationRequired = false 91 | 92 | let askAgainAction = UIMutableUserNotificationAction() 93 | askAgainAction.identifier = askAgainNotificationString 94 | askAgainAction.destructive = false 95 | askAgainAction.title = "AskAgain?" 96 | askAgainAction.activationMode = .Foreground 97 | askAgainAction.authenticationRequired = true 98 | 99 | 100 | let category = UIMutableUserNotificationCategory() 101 | category.identifier = notificationActionDemoString 102 | category.setActions([cancelAction, askAgainAction], forContext: .Minimal) 103 | return category 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /LevellingUp/NotificationAuthorisationViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | class NotificationAuthorisationViewController: UIViewController { 20 | 21 | let red = UIColor.redColor() 22 | let green = UIColor.greenColor() 23 | 24 | @IBOutlet weak var badgesLabel: UILabel! 25 | @IBOutlet weak var soundsLabel: UILabel! 26 | @IBOutlet weak var alertsLabel: UILabel! 27 | 28 | override func viewDidLoad() { 29 | super.viewDidLoad() 30 | 31 | title = "Notification Authorisation" 32 | 33 | // Register to get updates on notification authorisation status 34 | NSNotificationCenter.defaultCenter().addObserver(self, 35 | selector: "updateLabelsWithCurrentStatus", 36 | name: userNotificationSettingsKey, 37 | object: nil) 38 | 39 | // Do any additional setup after loading the view. 40 | updateLabelsWithCurrentStatus() 41 | } 42 | 43 | deinit { 44 | NSNotificationCenter.defaultCenter().removeObserver(self) 45 | } 46 | 47 | // MARK:- Actions 48 | @IBAction func handleRequestAction(sender: AnyObject) { 49 | let requestedTypes: UIUserNotificationType = .Alert | .Sound | .Badge 50 | requestNotificationsForTypes(requestedTypes) 51 | } 52 | 53 | @IBAction func handleJumpToSettings(sender: AnyObject) { 54 | let settingsUrl = NSURL(string: UIApplicationOpenSettingsURLString) 55 | UIApplication.sharedApplication().openURL(settingsUrl!) 56 | } 57 | 58 | // MARK:- Utils 59 | func updateLabelsWithCurrentStatus() { 60 | let types = UIApplication.sharedApplication().currentUserNotificationSettings().types 61 | 62 | badgesLabel.backgroundColor = (types & UIUserNotificationType.Badge == nil) ? red : green 63 | alertsLabel.backgroundColor = (types & UIUserNotificationType.Alert == nil) ? red : green 64 | soundsLabel.backgroundColor = (types & UIUserNotificationType.Sound == nil) ? red : green 65 | } 66 | 67 | private func requestNotificationsForTypes(types: UIUserNotificationType) { 68 | let settingsRequest = UIUserNotificationSettings(forTypes: types, categories: nil) 69 | UIApplication.sharedApplication().registerUserNotificationSettings(settingsRequest) 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /LevellingUp/PopoverContentViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | class PopoverContentViewController: UIViewController { 20 | 21 | @IBAction func handleDismissPressed(sender: AnyObject) { 22 | presentingViewController?.dismissViewControllerAnimated(true, completion: nil) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LevellingUp/PopoverViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2015 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import UIKit 18 | 19 | class PopoverViewController: UIViewController, UIPopoverPresentationControllerDelegate { 20 | 21 | @IBAction func handlePopoverPressed(sender: UIView) { 22 | let popoverVC = storyboard?.instantiateViewControllerWithIdentifier("PopoverContentVC") as! UIViewController 23 | popoverVC.modalPresentationStyle = .Popover 24 | 25 | presentViewController(popoverVC, animated: true, completion: nil) 26 | 27 | if let popoverController = popoverVC.popoverPresentationController { 28 | popoverController.sourceView = sender 29 | popoverController.sourceRect = sender.bounds 30 | popoverController.permittedArrowDirections = .Any 31 | popoverController.delegate = self 32 | } 33 | } 34 | 35 | 36 | // MARK:- UIPopoverPresentationControllerDelegate 37 | func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { 38 | return .FullScreen 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /LevellingUp/RotationViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | 18 | import UIKit 19 | 20 | class RotationViewController: UIViewController { 21 | 22 | @IBOutlet var monkeyLabels: [UILabel]! 23 | 24 | override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { 25 | super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator) 26 | let targetTransform = coordinator.targetTransform() 27 | if !CGAffineTransformIsIdentity(targetTransform) { 28 | coordinator.animateAlongsideTransition({ 29 | context in 30 | UIView.animateWithDuration(context.transitionDuration()) { 31 | for monkey in self.monkeyLabels { 32 | monkey.transform = CGAffineTransformInvert(targetTransform) 33 | } 34 | } 35 | }, completion: { 36 | context in 37 | UIView.animateWithDuration(1, delay: 0, usingSpringWithDamping: 0.3, 38 | initialSpringVelocity: 0, options: .allZeros, animations: { 39 | for monkey in self.monkeyLabels { 40 | monkey.transform = CGAffineTransformIdentity 41 | } 42 | }, 43 | completion: nil) 44 | }) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LevellingUp/countdown_new.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ScottLogic/iOS8-LevellingUp/96c831666837773d21d70b97fd282d8cd5cd8624/LevellingUp/countdown_new.mov -------------------------------------------------------------------------------- /LevellingUpTests/AsyncTestingTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import XCTest 18 | import LevellingUp 19 | import UIKit 20 | 21 | class HorseRaceTests: XCTestCase { 22 | 23 | var viewController: AsyncTestingViewController! 24 | var raceController: TwoHorseRaceController! 25 | 26 | override func setUp() { 27 | super.setUp() 28 | // Put setup code here. This method is called before the invocation of each test method in the class. 29 | 30 | // Get hold of the view controller 31 | let window = UIApplication.sharedApplication().delegate?.window! 32 | let storyboard = window?.rootViewController!.storyboard 33 | 34 | 35 | viewController = storyboard?.instantiateViewControllerWithIdentifier("AsyncTestingVC") as! AsyncTestingViewController 36 | window?.rootViewController = viewController 37 | raceController = viewController.raceController 38 | } 39 | 40 | override func tearDown() { 41 | // Put teardown code here. This method is called after the invocation of each test method in the class. 42 | viewController.raceController.reset() 43 | super.tearDown() 44 | } 45 | 46 | func testBasicAsyncMethod() { 47 | // Check that we get called back as expected 48 | let expectation = expectationWithDescription("Async Method") 49 | 50 | raceController.someKindOfAsyncMethod({ 51 | expectation.fulfill() 52 | }) 53 | 54 | waitForExpectationsWithTimeout(5, handler: nil) 55 | } 56 | 57 | 58 | func testRaceCallbacks() { 59 | // The horse race controller should callback each time a horse completes 60 | // the race. 61 | let h1Expectation = expectationWithDescription("Horse 1 should complete") 62 | let h2Expectation = expectationWithDescription("Horse 2 should complete") 63 | 64 | raceController.startRace(3, horseCrossedLineCallback: { 65 | (horse: Horse) in 66 | switch horse.horseView { 67 | case self.viewController.horse1: 68 | h1Expectation.fulfill() 69 | case self.viewController.horse2: 70 | h2Expectation.fulfill() 71 | default: 72 | XCTFail("Completetion called with unknown horse") 73 | } 74 | }) 75 | 76 | waitForExpectationsWithTimeout(5, handler: nil) 77 | } 78 | 79 | func testResetButtonEnabledOnceRaceComplete() { 80 | let expectation = keyValueObservingExpectationForObject(viewController.resetButton, keyPath: "enabled", expectedValue: true) 81 | 82 | // Simulate tapping the start race button 83 | viewController.handleStartRaceButton(viewController.startRaceButton) 84 | 85 | // Wait for the test to run 86 | waitForExpectationsWithTimeout(5, handler: nil) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /LevellingUpTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.shinobicontrols.$(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 | -------------------------------------------------------------------------------- /LevellingUpTests/LevellingUpTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LevellingUpTests.swift 3 | // LevellingUpTests 4 | // 5 | // Created by Sam Davies on 17/03/2015. 6 | // Copyright (c) 2015 shinobicontrols. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class LevellingUpTests: 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 | -------------------------------------------------------------------------------- /LevellingUpTests/MovingAverageTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2014 Scott Logic 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | 17 | import XCTest 18 | import LevellingUp 19 | import Foundation 20 | 21 | class MovingAverageTests: XCTestCase { 22 | 23 | let calculatorCreator : () -> MovingAverageCalculator = { return BetterMovingAverageCalculator() } 24 | var calculator: MovingAverageCalculator = BetterMovingAverageCalculator() 25 | 26 | override func setUp() { 27 | super.setUp() 28 | // Put setup code here. This method is called before the invocation of each test method in the class. 29 | // Reset the calculator 30 | calculator = calculatorCreator() 31 | } 32 | 33 | override func tearDown() { 34 | // Put teardown code here. This method is called after the invocation of each test method in the class. 35 | super.tearDown() 36 | } 37 | 38 | func testCopesWithEmptyArray() { 39 | let result: [Double] = calculator.calculateMovingAverage([Double]()) 40 | XCTAssertEqual(result.count, 0) 41 | } 42 | 43 | func testCopesWithArrayShorterThanWindow() { 44 | calculator.windowSize = 5 45 | let result = calculator.calculateMovingAverage([1.0, 2.0]) 46 | XCTAssertEqual(result.count, 0) 47 | } 48 | 49 | func testHasCorrectBehaviour() { 50 | calculator.windowSize = 4 51 | let input = [1.0, 2.0, 3.0, 4.0, 5.0, 5.0, 5.0, 6.0, 2.0, 2.0] 52 | let expected = [2.5, 3.5, 4.25, 4.75, 5.25, 4.5, 3.75] 53 | let result = calculator.calculateMovingAverage(input) 54 | XCTAssertEqual(result.count, expected.count) 55 | if(result.count == expected.count) { 56 | for i in 0.. Array { 77 | srand48(time(nil)) 78 | 79 | var result = [Double]() 80 | for i in 1..