├── .gitignore ├── LICENSE ├── NumberCounterMVC ├── NumberCounterMVC.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── NumberCounterMVC │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── NumberModel.swift │ └── NumberVC.swift ├── NumberCounterMVP ├── NumberCounterMVP.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── NumberCounterMVP │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── NumberModel.swift │ ├── NumberPresenter.swift │ ├── NumberVC.swift │ └── NumberView.swift └── NumberCounterMVPTests │ ├── Info.plist │ └── NumberPresenterTests.swift ├── NumberCounterMVVM ├── NumberCounterMVVM.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── NumberCounterMVVM │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── DataBinding.swift │ ├── Info.plist │ ├── NumberModel.swift │ ├── NumberVC.swift │ └── NumberViewModel.swift └── NumberCounterMVVMTests │ ├── Info.plist │ └── NumberCounterViewModelTests.swift └── NumberCounterVIPER ├── NumberCounterVIPER.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── NumberCounterVIPER ├── AppDelegate.swift ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist └── Modules └── NumberCounter ├── Entity └── NumberEntity.swift ├── Interactor ├── NumberInteractor.swift └── NumberInteractorIO.swift ├── Presenter ├── NumberPresenter.swift └── NumberPresenterProtocol.swift ├── View ├── NumberVC.swift └── NumberView.swift └── Wireframe └── Wireframe.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 viettx-demos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6F6DCE6B1F91D81B00127969 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCE6A1F91D81B00127969 /* AppDelegate.swift */; }; 11 | 6F6DCE6D1F91D81B00127969 /* NumberVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCE6C1F91D81B00127969 /* NumberVC.swift */; }; 12 | 6F6DCE701F91D81B00127969 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F6DCE6E1F91D81B00127969 /* Main.storyboard */; }; 13 | 6F6DCE721F91D81B00127969 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F6DCE711F91D81B00127969 /* Assets.xcassets */; }; 14 | 6F6DCE751F91D81B00127969 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F6DCE731F91D81B00127969 /* LaunchScreen.storyboard */; }; 15 | 6F6DCE7D1F91F93600127969 /* NumberModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCE7C1F91F93600127969 /* NumberModel.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 6F6DCE671F91D81B00127969 /* NumberCounterMVC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NumberCounterMVC.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 6F6DCE6A1F91D81B00127969 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 6F6DCE6C1F91D81B00127969 /* NumberVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberVC.swift; sourceTree = ""; }; 22 | 6F6DCE6F1F91D81B00127969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 6F6DCE711F91D81B00127969 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 6F6DCE741F91D81B00127969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 6F6DCE761F91D81B00127969 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 6F6DCE7C1F91F93600127969 /* NumberModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberModel.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 6F6DCE641F91D81B00127969 /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 6F6DCE5E1F91D81B00127969 = { 41 | isa = PBXGroup; 42 | children = ( 43 | 6F6DCE691F91D81B00127969 /* NumberCounterMVC */, 44 | 6F6DCE681F91D81B00127969 /* Products */, 45 | ); 46 | sourceTree = ""; 47 | }; 48 | 6F6DCE681F91D81B00127969 /* Products */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 6F6DCE671F91D81B00127969 /* NumberCounterMVC.app */, 52 | ); 53 | name = Products; 54 | sourceTree = ""; 55 | }; 56 | 6F6DCE691F91D81B00127969 /* NumberCounterMVC */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 6F6DCE6A1F91D81B00127969 /* AppDelegate.swift */, 60 | 6F6DCE7C1F91F93600127969 /* NumberModel.swift */, 61 | 6F6DCE6C1F91D81B00127969 /* NumberVC.swift */, 62 | 6F6DCE6E1F91D81B00127969 /* Main.storyboard */, 63 | 6F6DCE711F91D81B00127969 /* Assets.xcassets */, 64 | 6F6DCE731F91D81B00127969 /* LaunchScreen.storyboard */, 65 | 6F6DCE761F91D81B00127969 /* Info.plist */, 66 | ); 67 | path = NumberCounterMVC; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | 6F6DCE661F91D81B00127969 /* NumberCounterMVC */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = 6F6DCE791F91D81B00127969 /* Build configuration list for PBXNativeTarget "NumberCounterMVC" */; 76 | buildPhases = ( 77 | 6F6DCE631F91D81B00127969 /* Sources */, 78 | 6F6DCE641F91D81B00127969 /* Frameworks */, 79 | 6F6DCE651F91D81B00127969 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | ); 85 | name = NumberCounterMVC; 86 | productName = NumberCounterMVC; 87 | productReference = 6F6DCE671F91D81B00127969 /* NumberCounterMVC.app */; 88 | productType = "com.apple.product-type.application"; 89 | }; 90 | /* End PBXNativeTarget section */ 91 | 92 | /* Begin PBXProject section */ 93 | 6F6DCE5F1F91D81B00127969 /* Project object */ = { 94 | isa = PBXProject; 95 | attributes = { 96 | LastSwiftUpdateCheck = 0900; 97 | LastUpgradeCheck = 0900; 98 | ORGANIZATIONNAME = "Tran Viet"; 99 | TargetAttributes = { 100 | 6F6DCE661F91D81B00127969 = { 101 | CreatedOnToolsVersion = 9.0; 102 | ProvisioningStyle = Automatic; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = 6F6DCE621F91D81B00127969 /* Build configuration list for PBXProject "NumberCounterMVC" */; 107 | compatibilityVersion = "Xcode 8.0"; 108 | developmentRegion = en; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = 6F6DCE5E1F91D81B00127969; 115 | productRefGroup = 6F6DCE681F91D81B00127969 /* Products */; 116 | projectDirPath = ""; 117 | projectRoot = ""; 118 | targets = ( 119 | 6F6DCE661F91D81B00127969 /* NumberCounterMVC */, 120 | ); 121 | }; 122 | /* End PBXProject section */ 123 | 124 | /* Begin PBXResourcesBuildPhase section */ 125 | 6F6DCE651F91D81B00127969 /* Resources */ = { 126 | isa = PBXResourcesBuildPhase; 127 | buildActionMask = 2147483647; 128 | files = ( 129 | 6F6DCE751F91D81B00127969 /* LaunchScreen.storyboard in Resources */, 130 | 6F6DCE721F91D81B00127969 /* Assets.xcassets in Resources */, 131 | 6F6DCE701F91D81B00127969 /* Main.storyboard in Resources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXResourcesBuildPhase section */ 136 | 137 | /* Begin PBXSourcesBuildPhase section */ 138 | 6F6DCE631F91D81B00127969 /* Sources */ = { 139 | isa = PBXSourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | 6F6DCE6D1F91D81B00127969 /* NumberVC.swift in Sources */, 143 | 6F6DCE6B1F91D81B00127969 /* AppDelegate.swift in Sources */, 144 | 6F6DCE7D1F91F93600127969 /* NumberModel.swift in Sources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXSourcesBuildPhase section */ 149 | 150 | /* Begin PBXVariantGroup section */ 151 | 6F6DCE6E1F91D81B00127969 /* Main.storyboard */ = { 152 | isa = PBXVariantGroup; 153 | children = ( 154 | 6F6DCE6F1F91D81B00127969 /* Base */, 155 | ); 156 | name = Main.storyboard; 157 | sourceTree = ""; 158 | }; 159 | 6F6DCE731F91D81B00127969 /* LaunchScreen.storyboard */ = { 160 | isa = PBXVariantGroup; 161 | children = ( 162 | 6F6DCE741F91D81B00127969 /* Base */, 163 | ); 164 | name = LaunchScreen.storyboard; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXVariantGroup section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | 6F6DCE771F91D81B00127969 /* Debug */ = { 171 | isa = XCBuildConfiguration; 172 | buildSettings = { 173 | ALWAYS_SEARCH_USER_PATHS = NO; 174 | CLANG_ANALYZER_NONNULL = YES; 175 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 176 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 177 | CLANG_CXX_LIBRARY = "libc++"; 178 | CLANG_ENABLE_MODULES = YES; 179 | CLANG_ENABLE_OBJC_ARC = YES; 180 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 181 | CLANG_WARN_BOOL_CONVERSION = YES; 182 | CLANG_WARN_COMMA = YES; 183 | CLANG_WARN_CONSTANT_CONVERSION = YES; 184 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 185 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 186 | CLANG_WARN_EMPTY_BODY = YES; 187 | CLANG_WARN_ENUM_CONVERSION = YES; 188 | CLANG_WARN_INFINITE_RECURSION = YES; 189 | CLANG_WARN_INT_CONVERSION = YES; 190 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 191 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 192 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 193 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 194 | CLANG_WARN_STRICT_PROTOTYPES = YES; 195 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 196 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 197 | CLANG_WARN_UNREACHABLE_CODE = YES; 198 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 199 | CODE_SIGN_IDENTITY = "iPhone Developer"; 200 | COPY_PHASE_STRIP = NO; 201 | DEBUG_INFORMATION_FORMAT = dwarf; 202 | ENABLE_STRICT_OBJC_MSGSEND = YES; 203 | ENABLE_TESTABILITY = YES; 204 | GCC_C_LANGUAGE_STANDARD = gnu11; 205 | GCC_DYNAMIC_NO_PIC = NO; 206 | GCC_NO_COMMON_BLOCKS = YES; 207 | GCC_OPTIMIZATION_LEVEL = 0; 208 | GCC_PREPROCESSOR_DEFINITIONS = ( 209 | "DEBUG=1", 210 | "$(inherited)", 211 | ); 212 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 213 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 214 | GCC_WARN_UNDECLARED_SELECTOR = YES; 215 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 216 | GCC_WARN_UNUSED_FUNCTION = YES; 217 | GCC_WARN_UNUSED_VARIABLE = YES; 218 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 219 | MTL_ENABLE_DEBUG_INFO = YES; 220 | ONLY_ACTIVE_ARCH = YES; 221 | SDKROOT = iphoneos; 222 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 223 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 224 | }; 225 | name = Debug; 226 | }; 227 | 6F6DCE781F91D81B00127969 /* Release */ = { 228 | isa = XCBuildConfiguration; 229 | buildSettings = { 230 | ALWAYS_SEARCH_USER_PATHS = NO; 231 | CLANG_ANALYZER_NONNULL = YES; 232 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 238 | CLANG_WARN_BOOL_CONVERSION = YES; 239 | CLANG_WARN_COMMA = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INFINITE_RECURSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 249 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 250 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 251 | CLANG_WARN_STRICT_PROTOTYPES = YES; 252 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 253 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | CODE_SIGN_IDENTITY = "iPhone Developer"; 257 | COPY_PHASE_STRIP = NO; 258 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 259 | ENABLE_NS_ASSERTIONS = NO; 260 | ENABLE_STRICT_OBJC_MSGSEND = YES; 261 | GCC_C_LANGUAGE_STANDARD = gnu11; 262 | GCC_NO_COMMON_BLOCKS = YES; 263 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 264 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 265 | GCC_WARN_UNDECLARED_SELECTOR = YES; 266 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 267 | GCC_WARN_UNUSED_FUNCTION = YES; 268 | GCC_WARN_UNUSED_VARIABLE = YES; 269 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 270 | MTL_ENABLE_DEBUG_INFO = NO; 271 | SDKROOT = iphoneos; 272 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 273 | VALIDATE_PRODUCT = YES; 274 | }; 275 | name = Release; 276 | }; 277 | 6F6DCE7A1F91D81B00127969 /* Debug */ = { 278 | isa = XCBuildConfiguration; 279 | buildSettings = { 280 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 281 | CODE_SIGN_STYLE = Automatic; 282 | INFOPLIST_FILE = NumberCounterMVC/Info.plist; 283 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 284 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVC; 285 | PRODUCT_NAME = "$(TARGET_NAME)"; 286 | SWIFT_VERSION = 4.0; 287 | TARGETED_DEVICE_FAMILY = "1,2"; 288 | }; 289 | name = Debug; 290 | }; 291 | 6F6DCE7B1F91D81B00127969 /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 295 | CODE_SIGN_STYLE = Automatic; 296 | INFOPLIST_FILE = NumberCounterMVC/Info.plist; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVC; 299 | PRODUCT_NAME = "$(TARGET_NAME)"; 300 | SWIFT_VERSION = 4.0; 301 | TARGETED_DEVICE_FAMILY = "1,2"; 302 | }; 303 | name = Release; 304 | }; 305 | /* End XCBuildConfiguration section */ 306 | 307 | /* Begin XCConfigurationList section */ 308 | 6F6DCE621F91D81B00127969 /* Build configuration list for PBXProject "NumberCounterMVC" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | 6F6DCE771F91D81B00127969 /* Debug */, 312 | 6F6DCE781F91D81B00127969 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | defaultConfigurationName = Release; 316 | }; 317 | 6F6DCE791F91D81B00127969 /* Build configuration list for PBXNativeTarget "NumberCounterMVC" */ = { 318 | isa = XCConfigurationList; 319 | buildConfigurations = ( 320 | 6F6DCE7A1F91D81B00127969 /* Debug */, 321 | 6F6DCE7B1F91D81B00127969 /* Release */, 322 | ); 323 | defaultConfigurationIsVisible = 0; 324 | defaultConfigurationName = Release; 325 | }; 326 | /* End XCConfigurationList section */ 327 | }; 328 | rootObject = 6F6DCE5F1F91D81B00127969 /* Project object */; 329 | } 330 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NumberCounterMVC 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/NumberModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberModel.swift 3 | // NumberCounterMVC 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberModel { 12 | private var value:Int = 0 13 | 14 | init(value:Int) { 15 | self.value = value 16 | } 17 | 18 | func getValue() -> Int { 19 | return self.value 20 | } 21 | 22 | func setValue(value:Int) { 23 | self.value = value 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NumberCounterMVC/NumberCounterMVC/NumberVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NumberCounterMVC 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | class NumberVC: UIViewController { 11 | 12 | @IBOutlet weak var numberLabel: UILabel! 13 | @IBOutlet weak var decreaseButton: UIButton! 14 | 15 | var number:NumberModel! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | self.initDataWith(val: 3) 21 | self.updateUI() 22 | } 23 | 24 | override func didReceiveMemoryWarning() { 25 | super.didReceiveMemoryWarning() 26 | } 27 | 28 | func initDataWith(val:Int) { 29 | self.number = NumberModel(value: val) 30 | } 31 | 32 | func updateUI() { 33 | self.numberLabel.text = String(format: "%02d", arguments: [number.getValue()]) 34 | self.decreaseButton.isEnabled = number.getValue() > 0 35 | } 36 | 37 | @IBAction func decreaseAction(_ sender: UIButton) { 38 | self.number.setValue(value: self.number.getValue() - 1) 39 | self.updateUI() 40 | } 41 | 42 | @IBAction func increaseAction(_ sender: UIButton) { 43 | self.number.setValue(value: self.number.getValue() + 1) 44 | self.updateUI() 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6F6DCE8B1F91FA5600127969 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCE8A1F91FA5600127969 /* AppDelegate.swift */; }; 11 | 6F6DCE901F91FA5600127969 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F6DCE8E1F91FA5600127969 /* Main.storyboard */; }; 12 | 6F6DCE921F91FA5600127969 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F6DCE911F91FA5600127969 /* Assets.xcassets */; }; 13 | 6F6DCE951F91FA5600127969 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F6DCE931F91FA5600127969 /* LaunchScreen.storyboard */; }; 14 | 6F6DCE9E1F91FA9800127969 /* NumberVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCE9C1F91FA9800127969 /* NumberVC.swift */; }; 15 | 6F6DCE9F1F91FA9800127969 /* NumberModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCE9D1F91FA9800127969 /* NumberModel.swift */; }; 16 | 6F6DCEA11F925C4800127969 /* NumberPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCEA01F925C4800127969 /* NumberPresenter.swift */; }; 17 | 6F6DCEA31F925D1B00127969 /* NumberView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCEA21F925D1B00127969 /* NumberView.swift */; }; 18 | 6F6DCEAB1F927B5200127969 /* NumberPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F6DCEAA1F927B5200127969 /* NumberPresenterTests.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 6F6DCEAD1F927B5200127969 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 6F6DCE7F1F91FA5600127969 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 6F6DCE861F91FA5600127969; 27 | remoteInfo = NumberCounterMVP; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 6F6DCE871F91FA5600127969 /* NumberCounterMVP.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NumberCounterMVP.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 6F6DCE8A1F91FA5600127969 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | 6F6DCE8F1F91FA5600127969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | 6F6DCE911F91FA5600127969 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 36 | 6F6DCE941F91FA5600127969 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 37 | 6F6DCE961F91FA5600127969 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 6F6DCE9C1F91FA9800127969 /* NumberVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberVC.swift; sourceTree = ""; }; 39 | 6F6DCE9D1F91FA9800127969 /* NumberModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberModel.swift; sourceTree = ""; }; 40 | 6F6DCEA01F925C4800127969 /* NumberPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPresenter.swift; sourceTree = ""; }; 41 | 6F6DCEA21F925D1B00127969 /* NumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberView.swift; sourceTree = ""; }; 42 | 6F6DCEA81F927B5200127969 /* NumberCounterMVPTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NumberCounterMVPTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 6F6DCEAA1F927B5200127969 /* NumberPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPresenterTests.swift; sourceTree = ""; }; 44 | 6F6DCEAC1F927B5200127969 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 6F6DCE841F91FA5600127969 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | 6F6DCEA51F927B5200127969 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 6F6DCE7E1F91FA5600127969 = { 66 | isa = PBXGroup; 67 | children = ( 68 | 6F6DCE891F91FA5600127969 /* NumberCounterMVP */, 69 | 6F6DCEA91F927B5200127969 /* NumberCounterMVPTests */, 70 | 6F6DCE881F91FA5600127969 /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | 6F6DCE881F91FA5600127969 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 6F6DCE871F91FA5600127969 /* NumberCounterMVP.app */, 78 | 6F6DCEA81F927B5200127969 /* NumberCounterMVPTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | 6F6DCE891F91FA5600127969 /* NumberCounterMVP */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 6F6DCE8A1F91FA5600127969 /* AppDelegate.swift */, 87 | 6F6DCE9D1F91FA9800127969 /* NumberModel.swift */, 88 | 6F6DCEA01F925C4800127969 /* NumberPresenter.swift */, 89 | 6F6DCEA21F925D1B00127969 /* NumberView.swift */, 90 | 6F6DCE9C1F91FA9800127969 /* NumberVC.swift */, 91 | 6F6DCE8E1F91FA5600127969 /* Main.storyboard */, 92 | 6F6DCE911F91FA5600127969 /* Assets.xcassets */, 93 | 6F6DCE931F91FA5600127969 /* LaunchScreen.storyboard */, 94 | 6F6DCE961F91FA5600127969 /* Info.plist */, 95 | ); 96 | path = NumberCounterMVP; 97 | sourceTree = ""; 98 | }; 99 | 6F6DCEA91F927B5200127969 /* NumberCounterMVPTests */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 6F6DCEAA1F927B5200127969 /* NumberPresenterTests.swift */, 103 | 6F6DCEAC1F927B5200127969 /* Info.plist */, 104 | ); 105 | path = NumberCounterMVPTests; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | 6F6DCE861F91FA5600127969 /* NumberCounterMVP */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = 6F6DCE991F91FA5600127969 /* Build configuration list for PBXNativeTarget "NumberCounterMVP" */; 114 | buildPhases = ( 115 | 6F6DCE831F91FA5600127969 /* Sources */, 116 | 6F6DCE841F91FA5600127969 /* Frameworks */, 117 | 6F6DCE851F91FA5600127969 /* Resources */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = NumberCounterMVP; 124 | productName = NumberCounterMVP; 125 | productReference = 6F6DCE871F91FA5600127969 /* NumberCounterMVP.app */; 126 | productType = "com.apple.product-type.application"; 127 | }; 128 | 6F6DCEA71F927B5200127969 /* NumberCounterMVPTests */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = 6F6DCEAF1F927B5200127969 /* Build configuration list for PBXNativeTarget "NumberCounterMVPTests" */; 131 | buildPhases = ( 132 | 6F6DCEA41F927B5200127969 /* Sources */, 133 | 6F6DCEA51F927B5200127969 /* Frameworks */, 134 | 6F6DCEA61F927B5200127969 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | 6F6DCEAE1F927B5200127969 /* PBXTargetDependency */, 140 | ); 141 | name = NumberCounterMVPTests; 142 | productName = NumberCounterMVPTests; 143 | productReference = 6F6DCEA81F927B5200127969 /* NumberCounterMVPTests.xctest */; 144 | productType = "com.apple.product-type.bundle.unit-test"; 145 | }; 146 | /* End PBXNativeTarget section */ 147 | 148 | /* Begin PBXProject section */ 149 | 6F6DCE7F1F91FA5600127969 /* Project object */ = { 150 | isa = PBXProject; 151 | attributes = { 152 | LastSwiftUpdateCheck = 0900; 153 | LastUpgradeCheck = 0900; 154 | ORGANIZATIONNAME = "Tran Viet"; 155 | TargetAttributes = { 156 | 6F6DCE861F91FA5600127969 = { 157 | CreatedOnToolsVersion = 9.0; 158 | ProvisioningStyle = Automatic; 159 | }; 160 | 6F6DCEA71F927B5200127969 = { 161 | CreatedOnToolsVersion = 9.0; 162 | ProvisioningStyle = Automatic; 163 | TestTargetID = 6F6DCE861F91FA5600127969; 164 | }; 165 | }; 166 | }; 167 | buildConfigurationList = 6F6DCE821F91FA5600127969 /* Build configuration list for PBXProject "NumberCounterMVP" */; 168 | compatibilityVersion = "Xcode 8.0"; 169 | developmentRegion = en; 170 | hasScannedForEncodings = 0; 171 | knownRegions = ( 172 | en, 173 | Base, 174 | ); 175 | mainGroup = 6F6DCE7E1F91FA5600127969; 176 | productRefGroup = 6F6DCE881F91FA5600127969 /* Products */; 177 | projectDirPath = ""; 178 | projectRoot = ""; 179 | targets = ( 180 | 6F6DCE861F91FA5600127969 /* NumberCounterMVP */, 181 | 6F6DCEA71F927B5200127969 /* NumberCounterMVPTests */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXResourcesBuildPhase section */ 187 | 6F6DCE851F91FA5600127969 /* Resources */ = { 188 | isa = PBXResourcesBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | 6F6DCE951F91FA5600127969 /* LaunchScreen.storyboard in Resources */, 192 | 6F6DCE921F91FA5600127969 /* Assets.xcassets in Resources */, 193 | 6F6DCE901F91FA5600127969 /* Main.storyboard in Resources */, 194 | ); 195 | runOnlyForDeploymentPostprocessing = 0; 196 | }; 197 | 6F6DCEA61F927B5200127969 /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | }; 204 | /* End PBXResourcesBuildPhase section */ 205 | 206 | /* Begin PBXSourcesBuildPhase section */ 207 | 6F6DCE831F91FA5600127969 /* Sources */ = { 208 | isa = PBXSourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 6F6DCE9E1F91FA9800127969 /* NumberVC.swift in Sources */, 212 | 6F6DCEA11F925C4800127969 /* NumberPresenter.swift in Sources */, 213 | 6F6DCE9F1F91FA9800127969 /* NumberModel.swift in Sources */, 214 | 6F6DCEA31F925D1B00127969 /* NumberView.swift in Sources */, 215 | 6F6DCE8B1F91FA5600127969 /* AppDelegate.swift in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | 6F6DCEA41F927B5200127969 /* Sources */ = { 220 | isa = PBXSourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | 6F6DCEAB1F927B5200127969 /* NumberPresenterTests.swift in Sources */, 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | /* End PBXSourcesBuildPhase section */ 228 | 229 | /* Begin PBXTargetDependency section */ 230 | 6F6DCEAE1F927B5200127969 /* PBXTargetDependency */ = { 231 | isa = PBXTargetDependency; 232 | target = 6F6DCE861F91FA5600127969 /* NumberCounterMVP */; 233 | targetProxy = 6F6DCEAD1F927B5200127969 /* PBXContainerItemProxy */; 234 | }; 235 | /* End PBXTargetDependency section */ 236 | 237 | /* Begin PBXVariantGroup section */ 238 | 6F6DCE8E1F91FA5600127969 /* Main.storyboard */ = { 239 | isa = PBXVariantGroup; 240 | children = ( 241 | 6F6DCE8F1F91FA5600127969 /* Base */, 242 | ); 243 | name = Main.storyboard; 244 | sourceTree = ""; 245 | }; 246 | 6F6DCE931F91FA5600127969 /* LaunchScreen.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | 6F6DCE941F91FA5600127969 /* Base */, 250 | ); 251 | name = LaunchScreen.storyboard; 252 | sourceTree = ""; 253 | }; 254 | /* End PBXVariantGroup section */ 255 | 256 | /* Begin XCBuildConfiguration section */ 257 | 6F6DCE971F91FA5600127969 /* Debug */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_COMMA = YES; 270 | CLANG_WARN_CONSTANT_CONVERSION = YES; 271 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 272 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INFINITE_RECURSION = YES; 276 | CLANG_WARN_INT_CONVERSION = YES; 277 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 278 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 280 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 281 | CLANG_WARN_STRICT_PROTOTYPES = YES; 282 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 283 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 284 | CLANG_WARN_UNREACHABLE_CODE = YES; 285 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 286 | CODE_SIGN_IDENTITY = "iPhone Developer"; 287 | COPY_PHASE_STRIP = NO; 288 | DEBUG_INFORMATION_FORMAT = dwarf; 289 | ENABLE_STRICT_OBJC_MSGSEND = YES; 290 | ENABLE_TESTABILITY = YES; 291 | GCC_C_LANGUAGE_STANDARD = gnu11; 292 | GCC_DYNAMIC_NO_PIC = NO; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_OPTIMIZATION_LEVEL = 0; 295 | GCC_PREPROCESSOR_DEFINITIONS = ( 296 | "DEBUG=1", 297 | "$(inherited)", 298 | ); 299 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 300 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 301 | GCC_WARN_UNDECLARED_SELECTOR = YES; 302 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 303 | GCC_WARN_UNUSED_FUNCTION = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 306 | MTL_ENABLE_DEBUG_INFO = YES; 307 | ONLY_ACTIVE_ARCH = YES; 308 | SDKROOT = iphoneos; 309 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 310 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 311 | }; 312 | name = Debug; 313 | }; 314 | 6F6DCE981F91FA5600127969 /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ALWAYS_SEARCH_USER_PATHS = NO; 318 | CLANG_ANALYZER_NONNULL = YES; 319 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 320 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 321 | CLANG_CXX_LIBRARY = "libc++"; 322 | CLANG_ENABLE_MODULES = YES; 323 | CLANG_ENABLE_OBJC_ARC = YES; 324 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 325 | CLANG_WARN_BOOL_CONVERSION = YES; 326 | CLANG_WARN_COMMA = YES; 327 | CLANG_WARN_CONSTANT_CONVERSION = YES; 328 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 329 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INFINITE_RECURSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 335 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 337 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 338 | CLANG_WARN_STRICT_PROTOTYPES = YES; 339 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 340 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 341 | CLANG_WARN_UNREACHABLE_CODE = YES; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | CODE_SIGN_IDENTITY = "iPhone Developer"; 344 | COPY_PHASE_STRIP = NO; 345 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 346 | ENABLE_NS_ASSERTIONS = NO; 347 | ENABLE_STRICT_OBJC_MSGSEND = YES; 348 | GCC_C_LANGUAGE_STANDARD = gnu11; 349 | GCC_NO_COMMON_BLOCKS = YES; 350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 351 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 352 | GCC_WARN_UNDECLARED_SELECTOR = YES; 353 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 354 | GCC_WARN_UNUSED_FUNCTION = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 357 | MTL_ENABLE_DEBUG_INFO = NO; 358 | SDKROOT = iphoneos; 359 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 360 | VALIDATE_PRODUCT = YES; 361 | }; 362 | name = Release; 363 | }; 364 | 6F6DCE9A1F91FA5600127969 /* Debug */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 368 | CODE_SIGN_STYLE = Automatic; 369 | INFOPLIST_FILE = NumberCounterMVP/Info.plist; 370 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 371 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVP; 372 | PRODUCT_NAME = "$(TARGET_NAME)"; 373 | SWIFT_VERSION = 4.0; 374 | TARGETED_DEVICE_FAMILY = "1,2"; 375 | }; 376 | name = Debug; 377 | }; 378 | 6F6DCE9B1F91FA5600127969 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 382 | CODE_SIGN_STYLE = Automatic; 383 | INFOPLIST_FILE = NumberCounterMVP/Info.plist; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 385 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVP; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | SWIFT_VERSION = 4.0; 388 | TARGETED_DEVICE_FAMILY = "1,2"; 389 | }; 390 | name = Release; 391 | }; 392 | 6F6DCEB01F927B5200127969 /* Debug */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | BUNDLE_LOADER = "$(TEST_HOST)"; 396 | CODE_SIGN_STYLE = Automatic; 397 | INFOPLIST_FILE = NumberCounterMVPTests/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVPTests; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | SWIFT_VERSION = 4.0; 402 | TARGETED_DEVICE_FAMILY = "1,2"; 403 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NumberCounterMVP.app/NumberCounterMVP"; 404 | }; 405 | name = Debug; 406 | }; 407 | 6F6DCEB11F927B5200127969 /* Release */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | BUNDLE_LOADER = "$(TEST_HOST)"; 411 | CODE_SIGN_STYLE = Automatic; 412 | INFOPLIST_FILE = NumberCounterMVPTests/Info.plist; 413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 414 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVPTests; 415 | PRODUCT_NAME = "$(TARGET_NAME)"; 416 | SWIFT_VERSION = 4.0; 417 | TARGETED_DEVICE_FAMILY = "1,2"; 418 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NumberCounterMVP.app/NumberCounterMVP"; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | 6F6DCE821F91FA5600127969 /* Build configuration list for PBXProject "NumberCounterMVP" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 6F6DCE971F91FA5600127969 /* Debug */, 429 | 6F6DCE981F91FA5600127969 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | 6F6DCE991F91FA5600127969 /* Build configuration list for PBXNativeTarget "NumberCounterMVP" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 6F6DCE9A1F91FA5600127969 /* Debug */, 438 | 6F6DCE9B1F91FA5600127969 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | 6F6DCEAF1F927B5200127969 /* Build configuration list for PBXNativeTarget "NumberCounterMVPTests" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 6F6DCEB01F927B5200127969 /* Debug */, 447 | 6F6DCEB11F927B5200127969 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | /* End XCConfigurationList section */ 453 | }; 454 | rootObject = 6F6DCE7F1F91FA5600127969 /* Project object */; 455 | } 456 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NumberCounterMVP 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/NumberModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberModel.swift 3 | // NumberCounterMVP 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberModel { 12 | private var value:Int = 0 13 | 14 | init(value:Int) { 15 | self.value = value 16 | } 17 | 18 | func getValue() -> Int { 19 | return self.value 20 | } 21 | 22 | func setValue(value:Int) { 23 | self.value = value 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/NumberPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberPresenter.swift 3 | // NumberCounterMVP 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberPresenter { 12 | private var numberModel:NumberModel? 13 | private weak var numberView:NumberView? 14 | 15 | init(model:NumberModel) { 16 | self.numberModel = model 17 | } 18 | 19 | func attach(view:NumberView) { 20 | self.numberView = view 21 | 22 | updateView() 23 | } 24 | 25 | func increaseNumber() { 26 | guard let numberModel = self.numberModel else { return } 27 | numberModel.setValue(value: numberModel.getValue() + 1) 28 | 29 | self.updateView() 30 | } 31 | 32 | func decreaseNumber() { 33 | guard let numberModel = self.numberModel else { return } 34 | 35 | let currentValue = numberModel.getValue() 36 | if currentValue <= 0 { return } 37 | 38 | numberModel.setValue(value: currentValue - 1) 39 | 40 | self.updateView() 41 | } 42 | 43 | private func updateView() { 44 | guard let numberModel = self.numberModel, 45 | let numberView = self.numberView 46 | else { return } 47 | 48 | let text = String(format: "%02d", arguments: [numberModel.getValue()]) 49 | numberView.setTextNumber(text: text) 50 | 51 | numberView.updateDecreaseControl(enabled: numberModel.getValue() > 0) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/NumberVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberVC.swift 3 | // NumberCounterMVP 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NumberVC: UIViewController, NumberView { 12 | 13 | @IBOutlet weak var numberLabel: UILabel! 14 | @IBOutlet weak var decreaseButton: UIButton! 15 | 16 | private let numberPresenter = NumberPresenter(model: NumberModel(value: 3)) 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | self.numberPresenter.attach(view: self) 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | } 26 | 27 | @IBAction func decreaseAction(_ sender: UIButton) { 28 | self.numberPresenter.decreaseNumber() 29 | } 30 | 31 | @IBAction func increaseAction(_ sender: UIButton) { 32 | self.numberPresenter.increaseNumber() 33 | } 34 | 35 | // Implement methods from NumberView 36 | func setTextNumber(text: String) { 37 | self.numberLabel.text = text 38 | } 39 | 40 | func updateDecreaseControl(enabled: Bool) { 41 | self.decreaseButton.isEnabled = enabled 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVP/NumberView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberView.swift 3 | // NumberCounterMVP 4 | // 5 | // Created by Tran Viet on 10/14/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol NumberView:class { 12 | func setTextNumber(text:String) 13 | func updateDecreaseControl(enabled:Bool) 14 | } 15 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVPTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NumberCounterMVP/NumberCounterMVPTests/NumberPresenterTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberCounterMVPTests.swift 3 | // NumberCounterMVPTests 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import NumberCounterMVP 11 | 12 | class NumberViewMock:NumberView { 13 | var textValue = "" 14 | var descreaseEnabled = true 15 | 16 | func setTextNumber(text: String) { 17 | self.textValue = text 18 | } 19 | 20 | func updateDecreaseControl(enabled: Bool) { 21 | self.descreaseEnabled = enabled 22 | } 23 | } 24 | 25 | class NumberPresenterTests: XCTestCase { 26 | 27 | var numberModel:NumberModel! 28 | var numberPresenter:NumberPresenter! 29 | var numberViewMock = NumberViewMock() 30 | 31 | override func setUp() { 32 | super.setUp() 33 | 34 | self.numberModel = NumberModel(value: 10) 35 | self.numberPresenter = NumberPresenter(model: numberModel) 36 | self.numberPresenter.attach(view: numberViewMock) 37 | } 38 | 39 | override func tearDown() { 40 | // Put teardown code here. This method is called after the invocation of each test method in the class. 41 | super.tearDown() 42 | } 43 | 44 | func testInitValueMustBeTen() { 45 | XCTAssert(numberViewMock.textValue == "10", "Init number is not \"10\".") 46 | } 47 | 48 | func testIncreaseNumber() { 49 | self.numberPresenter.increaseNumber() 50 | 51 | XCTAssert(numberViewMock.textValue == "11", "Number is not \"11\" after increased.") 52 | } 53 | 54 | func testDecreaseNumber() { 55 | self.numberPresenter.decreaseNumber() 56 | 57 | XCTAssert(numberViewMock.textValue == "09", "Number is not \"09\" after decreased.") 58 | } 59 | 60 | func testDecreaseDisableWhenNumberIsZero() { 61 | for _ in 1...10 { 62 | self.numberPresenter.decreaseNumber() 63 | } 64 | 65 | XCTAssert(numberViewMock.descreaseEnabled == false, "Decrease control still enabled when number is 0.") 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6F5D05AD1F93632D00A1D101 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05AC1F93632D00A1D101 /* AppDelegate.swift */; }; 11 | 6F5D05B21F93632D00A1D101 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F5D05B01F93632D00A1D101 /* Main.storyboard */; }; 12 | 6F5D05B41F93632D00A1D101 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F5D05B31F93632D00A1D101 /* Assets.xcassets */; }; 13 | 6F5D05B71F93632D00A1D101 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F5D05B51F93632D00A1D101 /* LaunchScreen.storyboard */; }; 14 | 6F5D05C21F9365CA00A1D101 /* NumberViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05BE1F9365CA00A1D101 /* NumberViewModel.swift */; }; 15 | 6F5D05C31F9365CA00A1D101 /* NumberModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05BF1F9365CA00A1D101 /* NumberModel.swift */; }; 16 | 6F5D05C41F9365CA00A1D101 /* NumberVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05C01F9365CA00A1D101 /* NumberVC.swift */; }; 17 | 6F5D05C71F93665300A1D101 /* DataBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05C61F93665300A1D101 /* DataBinding.swift */; }; 18 | 6F5D05CF1F93762A00A1D101 /* NumberCounterViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05CE1F93762A00A1D101 /* NumberCounterViewModelTests.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 6F5D05D11F93762A00A1D101 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 6F5D05A11F93632D00A1D101 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 6F5D05A81F93632D00A1D101; 27 | remoteInfo = NumberCounterMVVM; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 6F5D05A91F93632D00A1D101 /* NumberCounterMVVM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NumberCounterMVVM.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 6F5D05AC1F93632D00A1D101 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | 6F5D05B11F93632D00A1D101 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | 6F5D05B31F93632D00A1D101 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 36 | 6F5D05B61F93632D00A1D101 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 37 | 6F5D05B81F93632D00A1D101 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | 6F5D05BE1F9365CA00A1D101 /* NumberViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberViewModel.swift; sourceTree = ""; }; 39 | 6F5D05BF1F9365CA00A1D101 /* NumberModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberModel.swift; sourceTree = ""; }; 40 | 6F5D05C01F9365CA00A1D101 /* NumberVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberVC.swift; sourceTree = ""; }; 41 | 6F5D05C61F93665300A1D101 /* DataBinding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataBinding.swift; sourceTree = ""; }; 42 | 6F5D05CC1F93762A00A1D101 /* NumberCounterMVVMTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NumberCounterMVVMTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 6F5D05CE1F93762A00A1D101 /* NumberCounterViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberCounterViewModelTests.swift; sourceTree = ""; }; 44 | 6F5D05D01F93762A00A1D101 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 6F5D05A61F93632D00A1D101 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | 6F5D05C91F93762A00A1D101 /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 6F5D05A01F93632D00A1D101 = { 66 | isa = PBXGroup; 67 | children = ( 68 | 6F5D05AB1F93632D00A1D101 /* NumberCounterMVVM */, 69 | 6F5D05CD1F93762A00A1D101 /* NumberCounterMVVMTests */, 70 | 6F5D05AA1F93632D00A1D101 /* Products */, 71 | ); 72 | sourceTree = ""; 73 | }; 74 | 6F5D05AA1F93632D00A1D101 /* Products */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 6F5D05A91F93632D00A1D101 /* NumberCounterMVVM.app */, 78 | 6F5D05CC1F93762A00A1D101 /* NumberCounterMVVMTests.xctest */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | 6F5D05AB1F93632D00A1D101 /* NumberCounterMVVM */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 6F5D05AC1F93632D00A1D101 /* AppDelegate.swift */, 87 | 6F5D05C61F93665300A1D101 /* DataBinding.swift */, 88 | 6F5D05BF1F9365CA00A1D101 /* NumberModel.swift */, 89 | 6F5D05BE1F9365CA00A1D101 /* NumberViewModel.swift */, 90 | 6F5D05C01F9365CA00A1D101 /* NumberVC.swift */, 91 | 6F5D05B01F93632D00A1D101 /* Main.storyboard */, 92 | 6F5D05B31F93632D00A1D101 /* Assets.xcassets */, 93 | 6F5D05B51F93632D00A1D101 /* LaunchScreen.storyboard */, 94 | 6F5D05B81F93632D00A1D101 /* Info.plist */, 95 | ); 96 | path = NumberCounterMVVM; 97 | sourceTree = ""; 98 | }; 99 | 6F5D05CD1F93762A00A1D101 /* NumberCounterMVVMTests */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 6F5D05CE1F93762A00A1D101 /* NumberCounterViewModelTests.swift */, 103 | 6F5D05D01F93762A00A1D101 /* Info.plist */, 104 | ); 105 | path = NumberCounterMVVMTests; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | 6F5D05A81F93632D00A1D101 /* NumberCounterMVVM */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = 6F5D05BB1F93632D00A1D101 /* Build configuration list for PBXNativeTarget "NumberCounterMVVM" */; 114 | buildPhases = ( 115 | 6F5D05A51F93632D00A1D101 /* Sources */, 116 | 6F5D05A61F93632D00A1D101 /* Frameworks */, 117 | 6F5D05A71F93632D00A1D101 /* Resources */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = NumberCounterMVVM; 124 | productName = NumberCounterMVVM; 125 | productReference = 6F5D05A91F93632D00A1D101 /* NumberCounterMVVM.app */; 126 | productType = "com.apple.product-type.application"; 127 | }; 128 | 6F5D05CB1F93762A00A1D101 /* NumberCounterMVVMTests */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = 6F5D05D51F93762A00A1D101 /* Build configuration list for PBXNativeTarget "NumberCounterMVVMTests" */; 131 | buildPhases = ( 132 | 6F5D05C81F93762A00A1D101 /* Sources */, 133 | 6F5D05C91F93762A00A1D101 /* Frameworks */, 134 | 6F5D05CA1F93762A00A1D101 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | 6F5D05D21F93762A00A1D101 /* PBXTargetDependency */, 140 | ); 141 | name = NumberCounterMVVMTests; 142 | productName = NumberCounterMVVMTests; 143 | productReference = 6F5D05CC1F93762A00A1D101 /* NumberCounterMVVMTests.xctest */; 144 | productType = "com.apple.product-type.bundle.unit-test"; 145 | }; 146 | /* End PBXNativeTarget section */ 147 | 148 | /* Begin PBXProject section */ 149 | 6F5D05A11F93632D00A1D101 /* Project object */ = { 150 | isa = PBXProject; 151 | attributes = { 152 | LastSwiftUpdateCheck = 0900; 153 | LastUpgradeCheck = 0900; 154 | ORGANIZATIONNAME = "Tran Viet"; 155 | TargetAttributes = { 156 | 6F5D05A81F93632D00A1D101 = { 157 | CreatedOnToolsVersion = 9.0; 158 | ProvisioningStyle = Automatic; 159 | }; 160 | 6F5D05CB1F93762A00A1D101 = { 161 | CreatedOnToolsVersion = 9.0; 162 | ProvisioningStyle = Automatic; 163 | TestTargetID = 6F5D05A81F93632D00A1D101; 164 | }; 165 | }; 166 | }; 167 | buildConfigurationList = 6F5D05A41F93632D00A1D101 /* Build configuration list for PBXProject "NumberCounterMVVM" */; 168 | compatibilityVersion = "Xcode 8.0"; 169 | developmentRegion = en; 170 | hasScannedForEncodings = 0; 171 | knownRegions = ( 172 | en, 173 | Base, 174 | ); 175 | mainGroup = 6F5D05A01F93632D00A1D101; 176 | productRefGroup = 6F5D05AA1F93632D00A1D101 /* Products */; 177 | projectDirPath = ""; 178 | projectRoot = ""; 179 | targets = ( 180 | 6F5D05A81F93632D00A1D101 /* NumberCounterMVVM */, 181 | 6F5D05CB1F93762A00A1D101 /* NumberCounterMVVMTests */, 182 | ); 183 | }; 184 | /* End PBXProject section */ 185 | 186 | /* Begin PBXResourcesBuildPhase section */ 187 | 6F5D05A71F93632D00A1D101 /* Resources */ = { 188 | isa = PBXResourcesBuildPhase; 189 | buildActionMask = 2147483647; 190 | files = ( 191 | 6F5D05B71F93632D00A1D101 /* LaunchScreen.storyboard in Resources */, 192 | 6F5D05B41F93632D00A1D101 /* Assets.xcassets in Resources */, 193 | 6F5D05B21F93632D00A1D101 /* Main.storyboard in Resources */, 194 | ); 195 | runOnlyForDeploymentPostprocessing = 0; 196 | }; 197 | 6F5D05CA1F93762A00A1D101 /* Resources */ = { 198 | isa = PBXResourcesBuildPhase; 199 | buildActionMask = 2147483647; 200 | files = ( 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | }; 204 | /* End PBXResourcesBuildPhase section */ 205 | 206 | /* Begin PBXSourcesBuildPhase section */ 207 | 6F5D05A51F93632D00A1D101 /* Sources */ = { 208 | isa = PBXSourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 6F5D05C41F9365CA00A1D101 /* NumberVC.swift in Sources */, 212 | 6F5D05C71F93665300A1D101 /* DataBinding.swift in Sources */, 213 | 6F5D05C21F9365CA00A1D101 /* NumberViewModel.swift in Sources */, 214 | 6F5D05C31F9365CA00A1D101 /* NumberModel.swift in Sources */, 215 | 6F5D05AD1F93632D00A1D101 /* AppDelegate.swift in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | 6F5D05C81F93762A00A1D101 /* Sources */ = { 220 | isa = PBXSourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | 6F5D05CF1F93762A00A1D101 /* NumberCounterViewModelTests.swift in Sources */, 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | /* End PBXSourcesBuildPhase section */ 228 | 229 | /* Begin PBXTargetDependency section */ 230 | 6F5D05D21F93762A00A1D101 /* PBXTargetDependency */ = { 231 | isa = PBXTargetDependency; 232 | target = 6F5D05A81F93632D00A1D101 /* NumberCounterMVVM */; 233 | targetProxy = 6F5D05D11F93762A00A1D101 /* PBXContainerItemProxy */; 234 | }; 235 | /* End PBXTargetDependency section */ 236 | 237 | /* Begin PBXVariantGroup section */ 238 | 6F5D05B01F93632D00A1D101 /* Main.storyboard */ = { 239 | isa = PBXVariantGroup; 240 | children = ( 241 | 6F5D05B11F93632D00A1D101 /* Base */, 242 | ); 243 | name = Main.storyboard; 244 | sourceTree = ""; 245 | }; 246 | 6F5D05B51F93632D00A1D101 /* LaunchScreen.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | 6F5D05B61F93632D00A1D101 /* Base */, 250 | ); 251 | name = LaunchScreen.storyboard; 252 | sourceTree = ""; 253 | }; 254 | /* End PBXVariantGroup section */ 255 | 256 | /* Begin XCBuildConfiguration section */ 257 | 6F5D05B91F93632D00A1D101 /* Debug */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_COMMA = YES; 270 | CLANG_WARN_CONSTANT_CONVERSION = YES; 271 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 272 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INFINITE_RECURSION = YES; 276 | CLANG_WARN_INT_CONVERSION = YES; 277 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 278 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 280 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 281 | CLANG_WARN_STRICT_PROTOTYPES = YES; 282 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 283 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 284 | CLANG_WARN_UNREACHABLE_CODE = YES; 285 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 286 | CODE_SIGN_IDENTITY = "iPhone Developer"; 287 | COPY_PHASE_STRIP = NO; 288 | DEBUG_INFORMATION_FORMAT = dwarf; 289 | ENABLE_STRICT_OBJC_MSGSEND = YES; 290 | ENABLE_TESTABILITY = YES; 291 | GCC_C_LANGUAGE_STANDARD = gnu11; 292 | GCC_DYNAMIC_NO_PIC = NO; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_OPTIMIZATION_LEVEL = 0; 295 | GCC_PREPROCESSOR_DEFINITIONS = ( 296 | "DEBUG=1", 297 | "$(inherited)", 298 | ); 299 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 300 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 301 | GCC_WARN_UNDECLARED_SELECTOR = YES; 302 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 303 | GCC_WARN_UNUSED_FUNCTION = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 306 | MTL_ENABLE_DEBUG_INFO = YES; 307 | ONLY_ACTIVE_ARCH = YES; 308 | SDKROOT = iphoneos; 309 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 310 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 311 | }; 312 | name = Debug; 313 | }; 314 | 6F5D05BA1F93632D00A1D101 /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ALWAYS_SEARCH_USER_PATHS = NO; 318 | CLANG_ANALYZER_NONNULL = YES; 319 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 320 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 321 | CLANG_CXX_LIBRARY = "libc++"; 322 | CLANG_ENABLE_MODULES = YES; 323 | CLANG_ENABLE_OBJC_ARC = YES; 324 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 325 | CLANG_WARN_BOOL_CONVERSION = YES; 326 | CLANG_WARN_COMMA = YES; 327 | CLANG_WARN_CONSTANT_CONVERSION = YES; 328 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 329 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INFINITE_RECURSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 335 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 337 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 338 | CLANG_WARN_STRICT_PROTOTYPES = YES; 339 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 340 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 341 | CLANG_WARN_UNREACHABLE_CODE = YES; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | CODE_SIGN_IDENTITY = "iPhone Developer"; 344 | COPY_PHASE_STRIP = NO; 345 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 346 | ENABLE_NS_ASSERTIONS = NO; 347 | ENABLE_STRICT_OBJC_MSGSEND = YES; 348 | GCC_C_LANGUAGE_STANDARD = gnu11; 349 | GCC_NO_COMMON_BLOCKS = YES; 350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 351 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 352 | GCC_WARN_UNDECLARED_SELECTOR = YES; 353 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 354 | GCC_WARN_UNUSED_FUNCTION = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 357 | MTL_ENABLE_DEBUG_INFO = NO; 358 | SDKROOT = iphoneos; 359 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 360 | VALIDATE_PRODUCT = YES; 361 | }; 362 | name = Release; 363 | }; 364 | 6F5D05BC1F93632D00A1D101 /* Debug */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 368 | CODE_SIGN_STYLE = Automatic; 369 | INFOPLIST_FILE = NumberCounterMVVM/Info.plist; 370 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 371 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVVM; 372 | PRODUCT_NAME = "$(TARGET_NAME)"; 373 | SWIFT_VERSION = 4.0; 374 | TARGETED_DEVICE_FAMILY = "1,2"; 375 | }; 376 | name = Debug; 377 | }; 378 | 6F5D05BD1F93632D00A1D101 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 382 | CODE_SIGN_STYLE = Automatic; 383 | INFOPLIST_FILE = NumberCounterMVVM/Info.plist; 384 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 385 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVVM; 386 | PRODUCT_NAME = "$(TARGET_NAME)"; 387 | SWIFT_VERSION = 4.0; 388 | TARGETED_DEVICE_FAMILY = "1,2"; 389 | }; 390 | name = Release; 391 | }; 392 | 6F5D05D31F93762A00A1D101 /* Debug */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | BUNDLE_LOADER = "$(TEST_HOST)"; 396 | CODE_SIGN_STYLE = Automatic; 397 | INFOPLIST_FILE = NumberCounterMVVMTests/Info.plist; 398 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 399 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVVMTests; 400 | PRODUCT_NAME = "$(TARGET_NAME)"; 401 | SWIFT_VERSION = 4.0; 402 | TARGETED_DEVICE_FAMILY = "1,2"; 403 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NumberCounterMVVM.app/NumberCounterMVVM"; 404 | }; 405 | name = Debug; 406 | }; 407 | 6F5D05D41F93762A00A1D101 /* Release */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | BUNDLE_LOADER = "$(TEST_HOST)"; 411 | CODE_SIGN_STYLE = Automatic; 412 | INFOPLIST_FILE = NumberCounterMVVMTests/Info.plist; 413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 414 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterMVVMTests; 415 | PRODUCT_NAME = "$(TARGET_NAME)"; 416 | SWIFT_VERSION = 4.0; 417 | TARGETED_DEVICE_FAMILY = "1,2"; 418 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NumberCounterMVVM.app/NumberCounterMVVM"; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | 6F5D05A41F93632D00A1D101 /* Build configuration list for PBXProject "NumberCounterMVVM" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 6F5D05B91F93632D00A1D101 /* Debug */, 429 | 6F5D05BA1F93632D00A1D101 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | 6F5D05BB1F93632D00A1D101 /* Build configuration list for PBXNativeTarget "NumberCounterMVVM" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 6F5D05BC1F93632D00A1D101 /* Debug */, 438 | 6F5D05BD1F93632D00A1D101 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | 6F5D05D51F93762A00A1D101 /* Build configuration list for PBXNativeTarget "NumberCounterMVVMTests" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 6F5D05D31F93762A00A1D101 /* Debug */, 447 | 6F5D05D41F93762A00A1D101 /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | /* End XCConfigurationList section */ 453 | }; 454 | rootObject = 6F5D05A11F93632D00A1D101 /* Project object */; 455 | } 456 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NumberCounterMVVM 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/DataBinding.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DataBinding.swift 3 | // NumberCounterMVVM 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class DataBinding { 12 | typealias Handler = (T) -> Void 13 | private var handlers:[Handler] = [] 14 | 15 | var value: T { 16 | didSet { 17 | self.fire() 18 | } 19 | } 20 | 21 | init(value: T) { 22 | self.value = value 23 | } 24 | 25 | func bind(hdl:@escaping Handler) { 26 | self.handlers.append(hdl) 27 | } 28 | 29 | func bindAndFire(hdl:@escaping Handler) { 30 | self.bind(hdl: hdl) 31 | self.fire() 32 | } 33 | 34 | private func fire() { 35 | for hdl in self.handlers { 36 | hdl(value) 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/NumberModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberModel.swift 3 | // NumberCounterMVVM 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberModel { 12 | private var value:Int = 0 13 | 14 | init(value:Int) { 15 | self.value = value 16 | } 17 | 18 | func getValue() -> Int { 19 | return self.value 20 | } 21 | 22 | func setValue(value:Int) { 23 | self.value = value 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/NumberVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberVC.swift 3 | // NumberCounterMVVM 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NumberVC: UIViewController { 12 | 13 | @IBOutlet weak var numberLabel: UILabel! 14 | @IBOutlet weak var decreaseButton: UIButton! 15 | 16 | private let numberViewModel = NumberViewModel(number: 3) 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | // Listen data stream from View Model 22 | numberViewModel.numberString?.bindAndFire(hdl: { [weak self] (text) in 23 | guard let `self` = self else { return } 24 | self.numberLabel.text = text 25 | }) 26 | 27 | numberViewModel.decreaseEnabled?.bindAndFire(hdl: { [weak self] (enabled) in 28 | guard let `self` = self else { return } 29 | self.decreaseButton.isEnabled = enabled 30 | }) 31 | } 32 | 33 | override func didReceiveMemoryWarning() { 34 | super.didReceiveMemoryWarning() 35 | } 36 | 37 | @IBAction func decreaseAction(_ sender: UIButton) { 38 | self.numberViewModel.decreaseNumber() 39 | } 40 | 41 | @IBAction func increaseAction(_ sender: UIButton) { 42 | self.numberViewModel.increaseNumber() 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVM/NumberViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberViewModel.swift 3 | // NumberCounterMVVM 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberViewModel { 12 | private var numberModel:NumberModel? 13 | var numberString:DataBinding? 14 | var decreaseEnabled:DataBinding? 15 | 16 | init(number:Int) { 17 | self.numberModel = NumberModel(value: number) 18 | 19 | self.numberString = DataBinding(value: formatNumber(number: number)) 20 | self.decreaseEnabled = DataBinding(value: number > 0) 21 | } 22 | 23 | func increaseNumber() { 24 | guard let numberModel = self.numberModel else { return } 25 | numberModel.setValue(value: numberModel.getValue() + 1) 26 | 27 | self.updateViewWithFireEvents() 28 | } 29 | 30 | func decreaseNumber() { 31 | guard let numberModel = self.numberModel else { return } 32 | 33 | let currentValue = numberModel.getValue() 34 | if currentValue <= 0 { return } 35 | 36 | numberModel.setValue(value: currentValue - 1) 37 | 38 | self.updateViewWithFireEvents() 39 | } 40 | 41 | private func formatNumber(number:Int) -> String { 42 | return String(format: "%02d", arguments: [number]) 43 | } 44 | 45 | private func updateViewWithFireEvents() { 46 | guard let numberModel = self.numberModel else { return } 47 | 48 | let currentValue = numberModel.getValue() 49 | let text = formatNumber(number: currentValue) 50 | 51 | // Fire event 52 | self.numberString?.value = text 53 | self.decreaseEnabled?.value = currentValue > 0 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVMTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NumberCounterMVVM/NumberCounterMVVMTests/NumberCounterViewModelTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberCounterViewModelTests.swift 3 | // NumberCounterViewModelTests 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import NumberCounterMVVM 11 | 12 | class NumberViewMock { 13 | var textValue = "" 14 | var descreaseEnabled = true 15 | 16 | init(viewModel:NumberViewModel) { 17 | viewModel.numberString?.bindAndFire(hdl: { [unowned self] (text) in 18 | self.textValue = text 19 | }) 20 | 21 | viewModel.decreaseEnabled?.bindAndFire(hdl: { [unowned self] (enabled) in 22 | self.descreaseEnabled = enabled 23 | }) 24 | } 25 | } 26 | 27 | class NumberCounterViewModelTests: XCTestCase { 28 | 29 | var numberViewModel:NumberViewModel! 30 | var numberViewMock:NumberViewMock! 31 | 32 | override func setUp() { 33 | super.setUp() 34 | 35 | self.numberViewModel = NumberViewModel(number: 10) 36 | self.numberViewMock = NumberViewMock(viewModel: self.numberViewModel) 37 | } 38 | 39 | override func tearDown() { 40 | super.tearDown() 41 | } 42 | 43 | func testInitValueMustBeTen() { 44 | XCTAssert(numberViewMock.textValue == "10", "Init number is not \"10\".") 45 | } 46 | 47 | func testIncreaseNumber() { 48 | self.numberViewModel.increaseNumber() 49 | 50 | XCTAssert(numberViewMock.textValue == "11", "Number is not \"11\" after increased.") 51 | } 52 | 53 | func testDecreaseNumber() { 54 | self.numberViewModel.decreaseNumber() 55 | 56 | XCTAssert(numberViewMock.textValue == "09", "Number is not \"09\" after decreased.") 57 | } 58 | 59 | func testDecreaseDisableWhenNumberIsZero() { 60 | for _ in 1...10 { 61 | self.numberViewModel.decreaseNumber() 62 | } 63 | 64 | XCTAssert(numberViewMock.descreaseEnabled == false, "Decrease control still enabled when number is 0.") 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 6F09B12D1F93A1310087F2A5 /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F09B12C1F93A1310087F2A5 /* Wireframe.swift */; }; 11 | 6F5D05E31F9396DF00A1D101 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D05E21F9396DF00A1D101 /* AppDelegate.swift */; }; 12 | 6F5D05E81F9396DF00A1D101 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F5D05E61F9396DF00A1D101 /* Main.storyboard */; }; 13 | 6F5D05EA1F9396DF00A1D101 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F5D05E91F9396DF00A1D101 /* Assets.xcassets */; }; 14 | 6F5D05ED1F9396DF00A1D101 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F5D05EB1F9396DF00A1D101 /* LaunchScreen.storyboard */; }; 15 | 6F5D06101F939BC400A1D101 /* NumberInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D060F1F939BC400A1D101 /* NumberInteractor.swift */; }; 16 | 6F5D06131F939C1D00A1D101 /* NumberEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D06121F939C1D00A1D101 /* NumberEntity.swift */; }; 17 | 6F5D06161F939EE600A1D101 /* NumberInteractorIO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D06151F939EE600A1D101 /* NumberInteractorIO.swift */; }; 18 | 6F5D06181F939F7A00A1D101 /* NumberPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D06171F939F7A00A1D101 /* NumberPresenter.swift */; }; 19 | 6F5D061A1F939F9B00A1D101 /* NumberPresenterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D06191F939F9B00A1D101 /* NumberPresenterProtocol.swift */; }; 20 | 6F5D061B1F939FBE00A1D101 /* NumberView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D060A1F939AF600A1D101 /* NumberView.swift */; }; 21 | 6F5D061C1F939FC300A1D101 /* NumberVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F5D060B1F939AF600A1D101 /* NumberVC.swift */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXFileReference section */ 25 | 6F09B12C1F93A1310087F2A5 /* Wireframe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = ""; }; 26 | 6F5D05DF1F9396DF00A1D101 /* NumberCounterVIPER.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NumberCounterVIPER.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 6F5D05E21F9396DF00A1D101 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 28 | 6F5D05E71F9396DF00A1D101 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | 6F5D05E91F9396DF00A1D101 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | 6F5D05EC1F9396DF00A1D101 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | 6F5D05EE1F9396DF00A1D101 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 6F5D060A1F939AF600A1D101 /* NumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberView.swift; sourceTree = ""; }; 33 | 6F5D060B1F939AF600A1D101 /* NumberVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberVC.swift; sourceTree = ""; }; 34 | 6F5D060F1F939BC400A1D101 /* NumberInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberInteractor.swift; sourceTree = ""; }; 35 | 6F5D06121F939C1D00A1D101 /* NumberEntity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberEntity.swift; sourceTree = ""; }; 36 | 6F5D06151F939EE600A1D101 /* NumberInteractorIO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberInteractorIO.swift; sourceTree = ""; }; 37 | 6F5D06171F939F7A00A1D101 /* NumberPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPresenter.swift; sourceTree = ""; }; 38 | 6F5D06191F939F9B00A1D101 /* NumberPresenterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPresenterProtocol.swift; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 6F5D05DC1F9396DF00A1D101 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | 6F09B12B1F93A1170087F2A5 /* Wireframe */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 6F09B12C1F93A1310087F2A5 /* Wireframe.swift */, 56 | ); 57 | path = Wireframe; 58 | sourceTree = ""; 59 | }; 60 | 6F5D05D61F9396DF00A1D101 = { 61 | isa = PBXGroup; 62 | children = ( 63 | 6F5D05E11F9396DF00A1D101 /* NumberCounterVIPER */, 64 | 6F5D05E01F9396DF00A1D101 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | 6F5D05E01F9396DF00A1D101 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 6F5D05DF1F9396DF00A1D101 /* NumberCounterVIPER.app */, 72 | ); 73 | name = Products; 74 | sourceTree = ""; 75 | }; 76 | 6F5D05E11F9396DF00A1D101 /* NumberCounterVIPER */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 6F5D06031F939AF600A1D101 /* Modules */, 80 | 6F5D05E21F9396DF00A1D101 /* AppDelegate.swift */, 81 | 6F5D05E61F9396DF00A1D101 /* Main.storyboard */, 82 | 6F5D05E91F9396DF00A1D101 /* Assets.xcassets */, 83 | 6F5D05EB1F9396DF00A1D101 /* LaunchScreen.storyboard */, 84 | 6F5D05EE1F9396DF00A1D101 /* Info.plist */, 85 | ); 86 | path = NumberCounterVIPER; 87 | sourceTree = ""; 88 | }; 89 | 6F5D06031F939AF600A1D101 /* Modules */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | 6F5D06041F939AF600A1D101 /* NumberCounter */, 93 | ); 94 | path = Modules; 95 | sourceTree = ""; 96 | }; 97 | 6F5D06041F939AF600A1D101 /* NumberCounter */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 6F09B12B1F93A1170087F2A5 /* Wireframe */, 101 | 6F5D06091F939AF600A1D101 /* View */, 102 | 6F5D06051F939AF600A1D101 /* Presenter */, 103 | 6F5D060C1F939AF600A1D101 /* Interactor */, 104 | 6F5D06111F939BF700A1D101 /* Entity */, 105 | ); 106 | path = NumberCounter; 107 | sourceTree = ""; 108 | }; 109 | 6F5D06051F939AF600A1D101 /* Presenter */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 6F5D06191F939F9B00A1D101 /* NumberPresenterProtocol.swift */, 113 | 6F5D06171F939F7A00A1D101 /* NumberPresenter.swift */, 114 | ); 115 | path = Presenter; 116 | sourceTree = ""; 117 | }; 118 | 6F5D06091F939AF600A1D101 /* View */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 6F5D060A1F939AF600A1D101 /* NumberView.swift */, 122 | 6F5D060B1F939AF600A1D101 /* NumberVC.swift */, 123 | ); 124 | path = View; 125 | sourceTree = ""; 126 | }; 127 | 6F5D060C1F939AF600A1D101 /* Interactor */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 6F5D060F1F939BC400A1D101 /* NumberInteractor.swift */, 131 | 6F5D06151F939EE600A1D101 /* NumberInteractorIO.swift */, 132 | ); 133 | path = Interactor; 134 | sourceTree = ""; 135 | }; 136 | 6F5D06111F939BF700A1D101 /* Entity */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 6F5D06121F939C1D00A1D101 /* NumberEntity.swift */, 140 | ); 141 | path = Entity; 142 | sourceTree = ""; 143 | }; 144 | /* End PBXGroup section */ 145 | 146 | /* Begin PBXNativeTarget section */ 147 | 6F5D05DE1F9396DF00A1D101 /* NumberCounterVIPER */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = 6F5D05F11F9396DF00A1D101 /* Build configuration list for PBXNativeTarget "NumberCounterVIPER" */; 150 | buildPhases = ( 151 | 6F5D05DB1F9396DF00A1D101 /* Sources */, 152 | 6F5D05DC1F9396DF00A1D101 /* Frameworks */, 153 | 6F5D05DD1F9396DF00A1D101 /* Resources */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | ); 159 | name = NumberCounterVIPER; 160 | productName = NumberCounterVIPER; 161 | productReference = 6F5D05DF1F9396DF00A1D101 /* NumberCounterVIPER.app */; 162 | productType = "com.apple.product-type.application"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | 6F5D05D71F9396DF00A1D101 /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastSwiftUpdateCheck = 0900; 171 | LastUpgradeCheck = 0900; 172 | ORGANIZATIONNAME = "Tran Viet"; 173 | TargetAttributes = { 174 | 6F5D05DE1F9396DF00A1D101 = { 175 | CreatedOnToolsVersion = 9.0; 176 | ProvisioningStyle = Automatic; 177 | }; 178 | }; 179 | }; 180 | buildConfigurationList = 6F5D05DA1F9396DF00A1D101 /* Build configuration list for PBXProject "NumberCounterVIPER" */; 181 | compatibilityVersion = "Xcode 8.0"; 182 | developmentRegion = en; 183 | hasScannedForEncodings = 0; 184 | knownRegions = ( 185 | en, 186 | Base, 187 | ); 188 | mainGroup = 6F5D05D61F9396DF00A1D101; 189 | productRefGroup = 6F5D05E01F9396DF00A1D101 /* Products */; 190 | projectDirPath = ""; 191 | projectRoot = ""; 192 | targets = ( 193 | 6F5D05DE1F9396DF00A1D101 /* NumberCounterVIPER */, 194 | ); 195 | }; 196 | /* End PBXProject section */ 197 | 198 | /* Begin PBXResourcesBuildPhase section */ 199 | 6F5D05DD1F9396DF00A1D101 /* Resources */ = { 200 | isa = PBXResourcesBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | 6F5D05ED1F9396DF00A1D101 /* LaunchScreen.storyboard in Resources */, 204 | 6F5D05EA1F9396DF00A1D101 /* Assets.xcassets in Resources */, 205 | 6F5D05E81F9396DF00A1D101 /* Main.storyboard in Resources */, 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | }; 209 | /* End PBXResourcesBuildPhase section */ 210 | 211 | /* Begin PBXSourcesBuildPhase section */ 212 | 6F5D05DB1F9396DF00A1D101 /* Sources */ = { 213 | isa = PBXSourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | 6F5D061C1F939FC300A1D101 /* NumberVC.swift in Sources */, 217 | 6F5D061B1F939FBE00A1D101 /* NumberView.swift in Sources */, 218 | 6F5D06161F939EE600A1D101 /* NumberInteractorIO.swift in Sources */, 219 | 6F5D06101F939BC400A1D101 /* NumberInteractor.swift in Sources */, 220 | 6F5D05E31F9396DF00A1D101 /* AppDelegate.swift in Sources */, 221 | 6F5D06131F939C1D00A1D101 /* NumberEntity.swift in Sources */, 222 | 6F5D06181F939F7A00A1D101 /* NumberPresenter.swift in Sources */, 223 | 6F09B12D1F93A1310087F2A5 /* Wireframe.swift in Sources */, 224 | 6F5D061A1F939F9B00A1D101 /* NumberPresenterProtocol.swift in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | /* End PBXSourcesBuildPhase section */ 229 | 230 | /* Begin PBXVariantGroup section */ 231 | 6F5D05E61F9396DF00A1D101 /* Main.storyboard */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | 6F5D05E71F9396DF00A1D101 /* Base */, 235 | ); 236 | name = Main.storyboard; 237 | sourceTree = ""; 238 | }; 239 | 6F5D05EB1F9396DF00A1D101 /* LaunchScreen.storyboard */ = { 240 | isa = PBXVariantGroup; 241 | children = ( 242 | 6F5D05EC1F9396DF00A1D101 /* Base */, 243 | ); 244 | name = LaunchScreen.storyboard; 245 | sourceTree = ""; 246 | }; 247 | /* End PBXVariantGroup section */ 248 | 249 | /* Begin XCBuildConfiguration section */ 250 | 6F5D05EF1F9396DF00A1D101 /* Debug */ = { 251 | isa = XCBuildConfiguration; 252 | buildSettings = { 253 | ALWAYS_SEARCH_USER_PATHS = NO; 254 | CLANG_ANALYZER_NONNULL = YES; 255 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 256 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 257 | CLANG_CXX_LIBRARY = "libc++"; 258 | CLANG_ENABLE_MODULES = YES; 259 | CLANG_ENABLE_OBJC_ARC = YES; 260 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 261 | CLANG_WARN_BOOL_CONVERSION = YES; 262 | CLANG_WARN_COMMA = YES; 263 | CLANG_WARN_CONSTANT_CONVERSION = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 266 | CLANG_WARN_EMPTY_BODY = YES; 267 | CLANG_WARN_ENUM_CONVERSION = YES; 268 | CLANG_WARN_INFINITE_RECURSION = YES; 269 | CLANG_WARN_INT_CONVERSION = YES; 270 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 271 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 272 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 273 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 274 | CLANG_WARN_STRICT_PROTOTYPES = YES; 275 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 276 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | CODE_SIGN_IDENTITY = "iPhone Developer"; 280 | COPY_PHASE_STRIP = NO; 281 | DEBUG_INFORMATION_FORMAT = dwarf; 282 | ENABLE_STRICT_OBJC_MSGSEND = YES; 283 | ENABLE_TESTABILITY = YES; 284 | GCC_C_LANGUAGE_STANDARD = gnu11; 285 | GCC_DYNAMIC_NO_PIC = NO; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_OPTIMIZATION_LEVEL = 0; 288 | GCC_PREPROCESSOR_DEFINITIONS = ( 289 | "DEBUG=1", 290 | "$(inherited)", 291 | ); 292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 294 | GCC_WARN_UNDECLARED_SELECTOR = YES; 295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 296 | GCC_WARN_UNUSED_FUNCTION = YES; 297 | GCC_WARN_UNUSED_VARIABLE = YES; 298 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 299 | MTL_ENABLE_DEBUG_INFO = YES; 300 | ONLY_ACTIVE_ARCH = YES; 301 | SDKROOT = iphoneos; 302 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 303 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 304 | }; 305 | name = Debug; 306 | }; 307 | 6F5D05F01F9396DF00A1D101 /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ALWAYS_SEARCH_USER_PATHS = NO; 311 | CLANG_ANALYZER_NONNULL = YES; 312 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 313 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 314 | CLANG_CXX_LIBRARY = "libc++"; 315 | CLANG_ENABLE_MODULES = YES; 316 | CLANG_ENABLE_OBJC_ARC = YES; 317 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 318 | CLANG_WARN_BOOL_CONVERSION = YES; 319 | CLANG_WARN_COMMA = YES; 320 | CLANG_WARN_CONSTANT_CONVERSION = YES; 321 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 322 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 323 | CLANG_WARN_EMPTY_BODY = YES; 324 | CLANG_WARN_ENUM_CONVERSION = YES; 325 | CLANG_WARN_INFINITE_RECURSION = YES; 326 | CLANG_WARN_INT_CONVERSION = YES; 327 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 328 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 329 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 330 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 331 | CLANG_WARN_STRICT_PROTOTYPES = YES; 332 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 333 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 334 | CLANG_WARN_UNREACHABLE_CODE = YES; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | CODE_SIGN_IDENTITY = "iPhone Developer"; 337 | COPY_PHASE_STRIP = NO; 338 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 339 | ENABLE_NS_ASSERTIONS = NO; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | GCC_C_LANGUAGE_STANDARD = gnu11; 342 | GCC_NO_COMMON_BLOCKS = YES; 343 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 344 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 345 | GCC_WARN_UNDECLARED_SELECTOR = YES; 346 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 347 | GCC_WARN_UNUSED_FUNCTION = YES; 348 | GCC_WARN_UNUSED_VARIABLE = YES; 349 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 350 | MTL_ENABLE_DEBUG_INFO = NO; 351 | SDKROOT = iphoneos; 352 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 353 | VALIDATE_PRODUCT = YES; 354 | }; 355 | name = Release; 356 | }; 357 | 6F5D05F21F9396DF00A1D101 /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 361 | CODE_SIGN_STYLE = Automatic; 362 | INFOPLIST_FILE = NumberCounterVIPER/Info.plist; 363 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 364 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterVIPER; 365 | PRODUCT_NAME = "$(TARGET_NAME)"; 366 | SWIFT_VERSION = 4.0; 367 | TARGETED_DEVICE_FAMILY = "1,2"; 368 | }; 369 | name = Debug; 370 | }; 371 | 6F5D05F31F9396DF00A1D101 /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | CODE_SIGN_STYLE = Automatic; 376 | INFOPLIST_FILE = NumberCounterVIPER/Info.plist; 377 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 378 | PRODUCT_BUNDLE_IDENTIFIER = vn.skylab.NumberCounterVIPER; 379 | PRODUCT_NAME = "$(TARGET_NAME)"; 380 | SWIFT_VERSION = 4.0; 381 | TARGETED_DEVICE_FAMILY = "1,2"; 382 | }; 383 | name = Release; 384 | }; 385 | /* End XCBuildConfiguration section */ 386 | 387 | /* Begin XCConfigurationList section */ 388 | 6F5D05DA1F9396DF00A1D101 /* Build configuration list for PBXProject "NumberCounterVIPER" */ = { 389 | isa = XCConfigurationList; 390 | buildConfigurations = ( 391 | 6F5D05EF1F9396DF00A1D101 /* Debug */, 392 | 6F5D05F01F9396DF00A1D101 /* Release */, 393 | ); 394 | defaultConfigurationIsVisible = 0; 395 | defaultConfigurationName = Release; 396 | }; 397 | 6F5D05F11F9396DF00A1D101 /* Build configuration list for PBXNativeTarget "NumberCounterVIPER" */ = { 398 | isa = XCConfigurationList; 399 | buildConfigurations = ( 400 | 6F5D05F21F9396DF00A1D101 /* Debug */, 401 | 6F5D05F31F9396DF00A1D101 /* Release */, 402 | ); 403 | defaultConfigurationIsVisible = 0; 404 | defaultConfigurationName = Release; 405 | }; 406 | /* End XCConfigurationList section */ 407 | }; 408 | rootObject = 6F5D05D71F9396DF00A1D101 /* Project object */; 409 | } 410 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | let numberModule = NumberWireframe() 21 | let numberVC = numberModule.getModule(initNumber: 3) 22 | 23 | self.window = UIWindow(frame: UIScreen.main.bounds) 24 | self.window?.rootViewController = numberVC 25 | self.window?.makeKeyAndVisible() 26 | 27 | return true 28 | } 29 | 30 | func applicationWillResignActive(_ application: UIApplication) { 31 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 32 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 33 | } 34 | 35 | func applicationDidEnterBackground(_ application: UIApplication) { 36 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | func applicationWillEnterForeground(_ application: UIApplication) { 41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 42 | } 43 | 44 | func applicationDidBecomeActive(_ application: UIApplication) { 45 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 46 | } 47 | 48 | func applicationWillTerminate(_ application: UIApplication) { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/Entity/NumberEntity.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberEntity.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberEntity { 12 | private var value:Int = 0 13 | 14 | init(value:Int) { 15 | self.value = value 16 | } 17 | 18 | func getValue() -> Int { 19 | return self.value 20 | } 21 | 22 | func setValue(value:Int) { 23 | self.value = value 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/Interactor/NumberInteractor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberInteractor.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberInteractor: NumberInteractorInput { 12 | 13 | var numberEntity:NumberEntity? 14 | weak var numberPresenter:NumberInteractorOutput? 15 | 16 | 17 | init(entity:NumberEntity) { 18 | self.numberEntity = entity 19 | } 20 | 21 | // Adopt NumberInteractorInput 22 | func getCurrentValue() { 23 | let currentValue = self.numberEntity?.getValue() ?? 0 24 | 25 | self.numberPresenter?.setNumber(number: currentValue) 26 | } 27 | 28 | func increase() { 29 | let currentValue = self.numberEntity?.getValue() ?? 0 30 | let newValue = currentValue + 1 31 | self.numberEntity?.setValue(value: newValue) 32 | 33 | self.numberPresenter?.setNumber(number: newValue) 34 | } 35 | 36 | func decrease() { 37 | let currentValue = self.numberEntity?.getValue() ?? 0 38 | let newValue = currentValue - 1 39 | 40 | self.numberEntity?.setValue(value: newValue) 41 | 42 | self.numberPresenter?.setNumber(number: newValue) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/Interactor/NumberInteractorIO.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberInteractorIO.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol NumberInteractorInput:class { 12 | func increase() 13 | func decrease() 14 | func getCurrentValue() 15 | } 16 | 17 | protocol NumberInteractorOutput:class { 18 | func setNumber(number:Int) 19 | } 20 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/Presenter/NumberPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberPresenter.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class NumberPresenter: NumberPresenterProtocol, NumberInteractorOutput { 12 | 13 | weak var numberView:NumberView? 14 | weak var numberInteractor:NumberInteractorInput? 15 | var numberWireframe:NumberWireframe? // not use in this project 16 | 17 | // Adopt NumberPresenterProtocol 18 | func increase() { 19 | self.numberInteractor?.increase() 20 | } 21 | 22 | func decrease() { 23 | self.numberInteractor?.decrease() 24 | } 25 | 26 | func getNumber() { 27 | self.numberInteractor?.getCurrentValue() 28 | } 29 | 30 | private func format(number:Int) -> String { 31 | return String(format: "%02d", arguments: [number]) 32 | } 33 | 34 | // Adopt NumberInteractorOutput 35 | func setNumber(number: Int) { 36 | let text = format(number: number) 37 | 38 | self.numberView?.setTextNumber(text: text) 39 | self.numberView?.updateDecreaseControl(enabled: number > 0) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/Presenter/NumberPresenterProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberPresenterProtocol.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol NumberPresenterProtocol:class { 12 | func getNumber() 13 | func increase() 14 | func decrease() 15 | } 16 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/View/NumberVC.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberVC.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NumberVC: UIViewController, NumberView { 12 | 13 | static let identifier = "numberVC" 14 | 15 | @IBOutlet weak var numberLabel: UILabel! 16 | @IBOutlet weak var decreaseButton: UIButton! 17 | 18 | var numberPresenter:NumberPresenterProtocol? 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | self.numberPresenter?.getNumber() 24 | } 25 | 26 | override func didReceiveMemoryWarning() { 27 | super.didReceiveMemoryWarning() 28 | } 29 | 30 | @IBAction func decreaseAction(_ sender: UIButton) { 31 | self.numberPresenter?.decrease() 32 | } 33 | 34 | @IBAction func increaseAction(_ sender: UIButton) { 35 | self.numberPresenter?.increase() 36 | } 37 | 38 | // Adopt NumberView 39 | func setTextNumber(text: String) { 40 | self.numberLabel.text = text 41 | } 42 | 43 | func updateDecreaseControl(enabled: Bool) { 44 | self.decreaseButton.isEnabled = enabled 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/View/NumberView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberView.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol NumberView:class { 12 | func setTextNumber(text:String) 13 | func updateDecreaseControl(enabled:Bool) 14 | } 15 | -------------------------------------------------------------------------------- /NumberCounterVIPER/NumberCounterVIPER/Modules/NumberCounter/Wireframe/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WireFrame.swift 3 | // NumberCounterVIPER 4 | // 5 | // Created by Tran Viet on 10/15/17. 6 | // Copyright © 2017 Tran Viet. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NumberWireframe { 12 | 13 | var interactor:NumberInteractor! 14 | var presenter:NumberPresenter! 15 | 16 | func getModule(initNumber numb:Int) -> UIViewController { 17 | 18 | let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main) 19 | let view = storyboard.instantiateViewController(withIdentifier: NumberVC.identifier) as! NumberVC 20 | let entity = NumberEntity(value: 3) 21 | let presenter = NumberPresenter() 22 | let interactor = NumberInteractor(entity: entity) 23 | 24 | view.numberPresenter = presenter 25 | presenter.numberView = view 26 | interactor.numberPresenter = presenter 27 | presenter.numberInteractor = interactor 28 | presenter.numberWireframe = self 29 | 30 | self.interactor = interactor 31 | self.presenter = presenter 32 | 33 | return view 34 | } 35 | } 36 | --------------------------------------------------------------------------------