├── .gitignore ├── 1. MassiveVC ├── MassiveVC.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── MassiveVC │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── DetailsViewController.swift │ ├── Info.plist │ └── MainViewController.swift ├── 2. ControllerVC ├── ControllerVC.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── ControllerVC │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── DetailsViewController.swift │ ├── Info.plist │ ├── MainView.swift │ ├── MainViewController.swift │ ├── MainViewProtocol.swift │ ├── TextLoader.swift │ ├── TextLoaderProtocol.swift │ └── Wireframe.swift ├── 3. VIPER aka MVP+Routing ├── VIPER.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── VIPER │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── DetailsViewController.swift │ ├── Info.plist │ ├── MainPresenter.swift │ ├── MainViewController.swift │ ├── MainViewControllerProtocol.swift │ ├── TextLoader.swift │ ├── TextLoaderProtocol.swift │ └── Wireframe.swift ├── 4. MVVM ├── MVVM.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── MVVM │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── DetailsViewController.swift │ ├── Info.plist │ ├── MainViewController.swift │ ├── MainViewModel.swift │ ├── MainViewModelProtocol.swift │ ├── TextLoader.swift │ ├── TextLoaderProtocol.swift │ └── Wireframe.swift ├── 5. MVP+Routing+Bindings ├── VIPER.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── VIPER │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── Context.swift │ ├── DetailsViewController.swift │ ├── Info.plist │ ├── MainModule.swift │ ├── MainPresenter.swift │ ├── MainViewController.swift │ ├── MainViewControllerProtocol.swift │ ├── Routing.swift │ ├── Signal.swift │ ├── TextLoader.swift │ ├── TextLoaderProtocol.swift │ └── Wireframe.swift └── VIPERTests │ ├── Info.plist │ ├── TestContext.swift │ └── VIPERTests.swift ├── 6. MVVM+Bindings ├── MVVM.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── MVVM │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ └── LaunchScreen.storyboard │ ├── DetailsViewController.swift │ ├── Info.plist │ ├── MainViewController.swift │ ├── MainViewModel.swift │ ├── MainViewModelProtocol.swift │ ├── Signal.swift │ ├── TextLoader.swift │ ├── TextLoaderProtocol.swift │ └── Wireframe.swift ├── 7. SilverMVC ├── SilverMVC.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── SilverMVC │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ └── LaunchScreen.storyboard │ ├── DetailsViewController.swift │ ├── DetailsViewProtocol.swift │ ├── Info.plist │ ├── MainPresenter.swift │ ├── MainViewController.swift │ ├── MainViewProtocol.swift │ ├── ProductionContext.swift │ ├── Routing+UIKit.swift │ ├── Routing.swift │ ├── Signal.swift │ ├── TextLoader.swift │ ├── TextLoaderProtocol.swift │ └── Wireframe.swift └── SilverMVCTests │ ├── Info.plist │ ├── SilverMVCTests.swift │ ├── TestContext.swift │ └── TestRouting.swift ├── LICENSE └── README.md /.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 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B7529AE1DDDE272002E9DE8 /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529AD1DDDE272002E9DE8 /* DetailsViewController.swift */; }; 11 | 1BE416481DDDDD5300BC63B3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE416471DDDDD5300BC63B3 /* AppDelegate.swift */; }; 12 | 1BE4164A1DDDDD5300BC63B3 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE416491DDDDD5300BC63B3 /* MainViewController.swift */; }; 13 | 1BE4164F1DDDDD5300BC63B3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1BE4164E1DDDDD5300BC63B3 /* Assets.xcassets */; }; 14 | 1BE416521DDDDD5300BC63B3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1BE416501DDDDD5300BC63B3 /* LaunchScreen.storyboard */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 1B7529AD1DDDE272002E9DE8 /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = ""; }; 19 | 1BE416441DDDDD5300BC63B3 /* MassiveVC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MassiveVC.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 1BE416471DDDDD5300BC63B3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 1BE416491DDDDD5300BC63B3 /* MainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 22 | 1BE4164E1DDDDD5300BC63B3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 1BE416511DDDDD5300BC63B3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 24 | 1BE416531DDDDD5300BC63B3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 1BE416411DDDDD5300BC63B3 /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 1BE4163B1DDDDD5300BC63B3 = { 39 | isa = PBXGroup; 40 | children = ( 41 | 1BE416461DDDDD5300BC63B3 /* MassiveVC */, 42 | 1BE416451DDDDD5300BC63B3 /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 1BE416451DDDDD5300BC63B3 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 1BE416441DDDDD5300BC63B3 /* MassiveVC.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 1BE416461DDDDD5300BC63B3 /* MassiveVC */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 1BE416471DDDDD5300BC63B3 /* AppDelegate.swift */, 58 | 1BE416491DDDDD5300BC63B3 /* MainViewController.swift */, 59 | 1B7529AD1DDDE272002E9DE8 /* DetailsViewController.swift */, 60 | 1BE4164E1DDDDD5300BC63B3 /* Assets.xcassets */, 61 | 1BE416501DDDDD5300BC63B3 /* LaunchScreen.storyboard */, 62 | 1BE416531DDDDD5300BC63B3 /* Info.plist */, 63 | ); 64 | path = MassiveVC; 65 | sourceTree = ""; 66 | }; 67 | /* End PBXGroup section */ 68 | 69 | /* Begin PBXNativeTarget section */ 70 | 1BE416431DDDDD5300BC63B3 /* MassiveVC */ = { 71 | isa = PBXNativeTarget; 72 | buildConfigurationList = 1BE416561DDDDD5300BC63B3 /* Build configuration list for PBXNativeTarget "MassiveVC" */; 73 | buildPhases = ( 74 | 1BE416401DDDDD5300BC63B3 /* Sources */, 75 | 1BE416411DDDDD5300BC63B3 /* Frameworks */, 76 | 1BE416421DDDDD5300BC63B3 /* Resources */, 77 | ); 78 | buildRules = ( 79 | ); 80 | dependencies = ( 81 | ); 82 | name = MassiveVC; 83 | productName = MassiveVC; 84 | productReference = 1BE416441DDDDD5300BC63B3 /* MassiveVC.app */; 85 | productType = "com.apple.product-type.application"; 86 | }; 87 | /* End PBXNativeTarget section */ 88 | 89 | /* Begin PBXProject section */ 90 | 1BE4163C1DDDDD5300BC63B3 /* Project object */ = { 91 | isa = PBXProject; 92 | attributes = { 93 | LastSwiftUpdateCheck = 0820; 94 | LastUpgradeCheck = 0820; 95 | ORGANIZATIONNAME = psharanda; 96 | TargetAttributes = { 97 | 1BE416431DDDDD5300BC63B3 = { 98 | CreatedOnToolsVersion = 8.2; 99 | ProvisioningStyle = Automatic; 100 | }; 101 | }; 102 | }; 103 | buildConfigurationList = 1BE4163F1DDDDD5300BC63B3 /* Build configuration list for PBXProject "MassiveVC" */; 104 | compatibilityVersion = "Xcode 3.2"; 105 | developmentRegion = English; 106 | hasScannedForEncodings = 0; 107 | knownRegions = ( 108 | en, 109 | Base, 110 | ); 111 | mainGroup = 1BE4163B1DDDDD5300BC63B3; 112 | productRefGroup = 1BE416451DDDDD5300BC63B3 /* Products */; 113 | projectDirPath = ""; 114 | projectRoot = ""; 115 | targets = ( 116 | 1BE416431DDDDD5300BC63B3 /* MassiveVC */, 117 | ); 118 | }; 119 | /* End PBXProject section */ 120 | 121 | /* Begin PBXResourcesBuildPhase section */ 122 | 1BE416421DDDDD5300BC63B3 /* Resources */ = { 123 | isa = PBXResourcesBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | 1BE416521DDDDD5300BC63B3 /* LaunchScreen.storyboard in Resources */, 127 | 1BE4164F1DDDDD5300BC63B3 /* Assets.xcassets in Resources */, 128 | ); 129 | runOnlyForDeploymentPostprocessing = 0; 130 | }; 131 | /* End PBXResourcesBuildPhase section */ 132 | 133 | /* Begin PBXSourcesBuildPhase section */ 134 | 1BE416401DDDDD5300BC63B3 /* Sources */ = { 135 | isa = PBXSourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | 1BE4164A1DDDDD5300BC63B3 /* MainViewController.swift in Sources */, 139 | 1BE416481DDDDD5300BC63B3 /* AppDelegate.swift in Sources */, 140 | 1B7529AE1DDDE272002E9DE8 /* DetailsViewController.swift in Sources */, 141 | ); 142 | runOnlyForDeploymentPostprocessing = 0; 143 | }; 144 | /* End PBXSourcesBuildPhase section */ 145 | 146 | /* Begin PBXVariantGroup section */ 147 | 1BE416501DDDDD5300BC63B3 /* LaunchScreen.storyboard */ = { 148 | isa = PBXVariantGroup; 149 | children = ( 150 | 1BE416511DDDDD5300BC63B3 /* Base */, 151 | ); 152 | name = LaunchScreen.storyboard; 153 | sourceTree = ""; 154 | }; 155 | /* End PBXVariantGroup section */ 156 | 157 | /* Begin XCBuildConfiguration section */ 158 | 1BE416541DDDDD5300BC63B3 /* Debug */ = { 159 | isa = XCBuildConfiguration; 160 | buildSettings = { 161 | ALWAYS_SEARCH_USER_PATHS = NO; 162 | CLANG_ANALYZER_NONNULL = YES; 163 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 164 | CLANG_CXX_LIBRARY = "libc++"; 165 | CLANG_ENABLE_MODULES = YES; 166 | CLANG_ENABLE_OBJC_ARC = YES; 167 | CLANG_WARN_BOOL_CONVERSION = YES; 168 | CLANG_WARN_CONSTANT_CONVERSION = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 176 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 177 | CLANG_WARN_UNREACHABLE_CODE = YES; 178 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 179 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 180 | COPY_PHASE_STRIP = NO; 181 | DEBUG_INFORMATION_FORMAT = dwarf; 182 | ENABLE_STRICT_OBJC_MSGSEND = YES; 183 | ENABLE_TESTABILITY = YES; 184 | GCC_C_LANGUAGE_STANDARD = gnu99; 185 | GCC_DYNAMIC_NO_PIC = NO; 186 | GCC_NO_COMMON_BLOCKS = YES; 187 | GCC_OPTIMIZATION_LEVEL = 0; 188 | GCC_PREPROCESSOR_DEFINITIONS = ( 189 | "DEBUG=1", 190 | "$(inherited)", 191 | ); 192 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 193 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 194 | GCC_WARN_UNDECLARED_SELECTOR = YES; 195 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 196 | GCC_WARN_UNUSED_FUNCTION = YES; 197 | GCC_WARN_UNUSED_VARIABLE = YES; 198 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 199 | MTL_ENABLE_DEBUG_INFO = YES; 200 | ONLY_ACTIVE_ARCH = YES; 201 | SDKROOT = iphoneos; 202 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 203 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 204 | }; 205 | name = Debug; 206 | }; 207 | 1BE416551DDDDD5300BC63B3 /* Release */ = { 208 | isa = XCBuildConfiguration; 209 | buildSettings = { 210 | ALWAYS_SEARCH_USER_PATHS = NO; 211 | CLANG_ANALYZER_NONNULL = YES; 212 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 213 | CLANG_CXX_LIBRARY = "libc++"; 214 | CLANG_ENABLE_MODULES = YES; 215 | CLANG_ENABLE_OBJC_ARC = YES; 216 | CLANG_WARN_BOOL_CONVERSION = YES; 217 | CLANG_WARN_CONSTANT_CONVERSION = YES; 218 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 219 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 220 | CLANG_WARN_EMPTY_BODY = YES; 221 | CLANG_WARN_ENUM_CONVERSION = YES; 222 | CLANG_WARN_INFINITE_RECURSION = YES; 223 | CLANG_WARN_INT_CONVERSION = YES; 224 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 225 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 226 | CLANG_WARN_UNREACHABLE_CODE = YES; 227 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 228 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 229 | COPY_PHASE_STRIP = NO; 230 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 231 | ENABLE_NS_ASSERTIONS = NO; 232 | ENABLE_STRICT_OBJC_MSGSEND = YES; 233 | GCC_C_LANGUAGE_STANDARD = gnu99; 234 | GCC_NO_COMMON_BLOCKS = YES; 235 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 236 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 237 | GCC_WARN_UNDECLARED_SELECTOR = YES; 238 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 239 | GCC_WARN_UNUSED_FUNCTION = YES; 240 | GCC_WARN_UNUSED_VARIABLE = YES; 241 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 242 | MTL_ENABLE_DEBUG_INFO = NO; 243 | SDKROOT = iphoneos; 244 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 245 | VALIDATE_PRODUCT = YES; 246 | }; 247 | name = Release; 248 | }; 249 | 1BE416571DDDDD5300BC63B3 /* Debug */ = { 250 | isa = XCBuildConfiguration; 251 | buildSettings = { 252 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 253 | INFOPLIST_FILE = MassiveVC/Info.plist; 254 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 255 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.MassiveVC; 256 | PRODUCT_NAME = "$(TARGET_NAME)"; 257 | SWIFT_VERSION = 3.0; 258 | }; 259 | name = Debug; 260 | }; 261 | 1BE416581DDDDD5300BC63B3 /* Release */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 265 | INFOPLIST_FILE = MassiveVC/Info.plist; 266 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 267 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.MassiveVC; 268 | PRODUCT_NAME = "$(TARGET_NAME)"; 269 | SWIFT_VERSION = 3.0; 270 | }; 271 | name = Release; 272 | }; 273 | /* End XCBuildConfiguration section */ 274 | 275 | /* Begin XCConfigurationList section */ 276 | 1BE4163F1DDDDD5300BC63B3 /* Build configuration list for PBXProject "MassiveVC" */ = { 277 | isa = XCConfigurationList; 278 | buildConfigurations = ( 279 | 1BE416541DDDDD5300BC63B3 /* Debug */, 280 | 1BE416551DDDDD5300BC63B3 /* Release */, 281 | ); 282 | defaultConfigurationIsVisible = 0; 283 | defaultConfigurationName = Release; 284 | }; 285 | 1BE416561DDDDD5300BC63B3 /* Build configuration list for PBXNativeTarget "MassiveVC" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | 1BE416571DDDDD5300BC63B3 /* Debug */, 289 | 1BE416581DDDDD5300BC63B3 /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | defaultConfigurationName = Release; 293 | }; 294 | /* End XCConfigurationList section */ 295 | }; 296 | rootObject = 1BE4163C1DDDDD5300BC63B3 /* Project object */; 297 | } 298 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var window: UIWindow? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | window = UIWindow(frame: UIScreen.main.bounds) 17 | window?.rootViewController = UINavigationController(rootViewController: MainViewController()) 18 | window?.makeKeyAndVisible() 19 | return true 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC/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 | 27 | 28 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController { 9 | 10 | 11 | private lazy var label = UILabel() 12 | 13 | private let text: String? 14 | 15 | init(text: String?) { 16 | self.text = text 17 | super.init(nibName: nil, bundle: nil) 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | title = "Details" 28 | 29 | view.backgroundColor = .white 30 | 31 | label.numberOfLines = 0 32 | label.text = text?.uppercased() 33 | view.addSubview(label) 34 | } 35 | 36 | override func viewDidLayoutSubviews() { 37 | super.viewDidLayoutSubviews() 38 | 39 | 40 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 41 | 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /1. MassiveVC/MassiveVC/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainViewController: UIViewController { 9 | 10 | private lazy var button = UIButton(type: .system) 11 | private lazy var label = UILabel() 12 | private lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 13 | 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | title = "Massive VC" 19 | 20 | view.backgroundColor = .white 21 | 22 | view.addSubview(activityIndicator) 23 | 24 | button.setTitle("Load", for: .normal) 25 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 26 | view.addSubview(button) 27 | 28 | label.numberOfLines = 0 29 | view.addSubview(label) 30 | 31 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(doneClicked)) 32 | navigationItem.rightBarButtonItem?.isEnabled = false 33 | } 34 | 35 | override func viewDidLayoutSubviews() { 36 | super.viewDidLayoutSubviews() 37 | 38 | activityIndicator.frame = view.bounds 39 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 40 | button.frame = CGRect(x: 20, y: view.bounds.height - 60, width: view.bounds.width - 40, height: 40) 41 | } 42 | 43 | @objc private func doneClicked() { 44 | navigationController?.pushViewController(DetailsViewController(text: label.text), animated: true) 45 | } 46 | 47 | @objc private func buttonClicked() { 48 | activityIndicator.startAnimating() 49 | label.text = nil 50 | navigationItem.rightBarButtonItem?.isEnabled = false 51 | 52 | loadText { 53 | self.activityIndicator.stopAnimating() 54 | self.label.text = $0 55 | self.navigationItem.rightBarButtonItem?.isEnabled = true 56 | } 57 | } 58 | 59 | private func loadText(completion: @escaping (String)->Void) { 60 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 61 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 62 | } 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B6869F11DDF0A1D006B134E /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B6869F01DDF0A1D006B134E /* Wireframe.swift */; }; 11 | 1B7529BC1DDDE4BF002E9DE8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529BB1DDDE4BF002E9DE8 /* AppDelegate.swift */; }; 12 | 1B7529C31DDDE4BF002E9DE8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B7529C21DDDE4BF002E9DE8 /* Assets.xcassets */; }; 13 | 1B7529C61DDDE4BF002E9DE8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B7529C41DDDE4BF002E9DE8 /* LaunchScreen.storyboard */; }; 14 | 1B7529CF1DDDE4E8002E9DE8 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529CD1DDDE4E8002E9DE8 /* MainViewController.swift */; }; 15 | 1B7529D01DDDE4E8002E9DE8 /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529CE1DDDE4E8002E9DE8 /* DetailsViewController.swift */; }; 16 | 1B7529D21DDDE51F002E9DE8 /* TextLoaderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529D11DDDE51F002E9DE8 /* TextLoaderProtocol.swift */; }; 17 | 1B7529D71DDDE56F002E9DE8 /* TextLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529D61DDDE56F002E9DE8 /* TextLoader.swift */; }; 18 | 1B7529D91DDDE59F002E9DE8 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529D81DDDE59F002E9DE8 /* MainView.swift */; }; 19 | 1B7529DB1DDDE5AA002E9DE8 /* MainViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B7529DA1DDDE5AA002E9DE8 /* MainViewProtocol.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 1B6869F01DDF0A1D006B134E /* Wireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = ""; }; 24 | 1B7529B81DDDE4BF002E9DE8 /* ControllerVC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ControllerVC.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 1B7529BB1DDDE4BF002E9DE8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | 1B7529C21DDDE4BF002E9DE8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 1B7529C51DDDE4BF002E9DE8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 1B7529C71DDDE4BF002E9DE8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | 1B7529CD1DDDE4E8002E9DE8 /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 30 | 1B7529CE1DDDE4E8002E9DE8 /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = ""; }; 31 | 1B7529D11DDDE51F002E9DE8 /* TextLoaderProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoaderProtocol.swift; sourceTree = ""; }; 32 | 1B7529D61DDDE56F002E9DE8 /* TextLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoader.swift; sourceTree = ""; }; 33 | 1B7529D81DDDE59F002E9DE8 /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; 34 | 1B7529DA1DDDE5AA002E9DE8 /* MainViewProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewProtocol.swift; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 1B7529B51DDDE4BF002E9DE8 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 1B6869EF1DDF0A0E006B134E /* Routing */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 1B6869F01DDF0A1D006B134E /* Wireframe.swift */, 52 | ); 53 | name = Routing; 54 | sourceTree = ""; 55 | }; 56 | 1B7529AF1DDDE4BF002E9DE8 = { 57 | isa = PBXGroup; 58 | children = ( 59 | 1B7529BA1DDDE4BF002E9DE8 /* ControllerVC */, 60 | 1B7529B91DDDE4BF002E9DE8 /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 1B7529B91DDDE4BF002E9DE8 /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 1B7529B81DDDE4BF002E9DE8 /* ControllerVC.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 1B7529BA1DDDE4BF002E9DE8 /* ControllerVC */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 1B7529D31DDDE525002E9DE8 /* Model */, 76 | 1B7529D41DDDE52A002E9DE8 /* View */, 77 | 1B7529D51DDDE52E002E9DE8 /* Controller */, 78 | 1B6869EF1DDF0A0E006B134E /* Routing */, 79 | 1B7529BB1DDDE4BF002E9DE8 /* AppDelegate.swift */, 80 | 1B7529C21DDDE4BF002E9DE8 /* Assets.xcassets */, 81 | 1B7529C41DDDE4BF002E9DE8 /* LaunchScreen.storyboard */, 82 | 1B7529C71DDDE4BF002E9DE8 /* Info.plist */, 83 | ); 84 | path = ControllerVC; 85 | sourceTree = ""; 86 | }; 87 | 1B7529D31DDDE525002E9DE8 /* Model */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 1B7529D11DDDE51F002E9DE8 /* TextLoaderProtocol.swift */, 91 | 1B7529D61DDDE56F002E9DE8 /* TextLoader.swift */, 92 | ); 93 | name = Model; 94 | sourceTree = ""; 95 | }; 96 | 1B7529D41DDDE52A002E9DE8 /* View */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 1B7529DA1DDDE5AA002E9DE8 /* MainViewProtocol.swift */, 100 | 1B7529D81DDDE59F002E9DE8 /* MainView.swift */, 101 | ); 102 | name = View; 103 | sourceTree = ""; 104 | }; 105 | 1B7529D51DDDE52E002E9DE8 /* Controller */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 1B7529CD1DDDE4E8002E9DE8 /* MainViewController.swift */, 109 | 1B7529CE1DDDE4E8002E9DE8 /* DetailsViewController.swift */, 110 | ); 111 | name = Controller; 112 | sourceTree = ""; 113 | }; 114 | /* End PBXGroup section */ 115 | 116 | /* Begin PBXNativeTarget section */ 117 | 1B7529B71DDDE4BF002E9DE8 /* ControllerVC */ = { 118 | isa = PBXNativeTarget; 119 | buildConfigurationList = 1B7529CA1DDDE4BF002E9DE8 /* Build configuration list for PBXNativeTarget "ControllerVC" */; 120 | buildPhases = ( 121 | 1B7529B41DDDE4BF002E9DE8 /* Sources */, 122 | 1B7529B51DDDE4BF002E9DE8 /* Frameworks */, 123 | 1B7529B61DDDE4BF002E9DE8 /* Resources */, 124 | ); 125 | buildRules = ( 126 | ); 127 | dependencies = ( 128 | ); 129 | name = ControllerVC; 130 | productName = ControllerVC; 131 | productReference = 1B7529B81DDDE4BF002E9DE8 /* ControllerVC.app */; 132 | productType = "com.apple.product-type.application"; 133 | }; 134 | /* End PBXNativeTarget section */ 135 | 136 | /* Begin PBXProject section */ 137 | 1B7529B01DDDE4BF002E9DE8 /* Project object */ = { 138 | isa = PBXProject; 139 | attributes = { 140 | LastSwiftUpdateCheck = 0820; 141 | LastUpgradeCheck = 0820; 142 | ORGANIZATIONNAME = psharanda; 143 | TargetAttributes = { 144 | 1B7529B71DDDE4BF002E9DE8 = { 145 | CreatedOnToolsVersion = 8.2; 146 | ProvisioningStyle = Automatic; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = 1B7529B31DDDE4BF002E9DE8 /* Build configuration list for PBXProject "ControllerVC" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = 1B7529AF1DDDE4BF002E9DE8; 159 | productRefGroup = 1B7529B91DDDE4BF002E9DE8 /* Products */; 160 | projectDirPath = ""; 161 | projectRoot = ""; 162 | targets = ( 163 | 1B7529B71DDDE4BF002E9DE8 /* ControllerVC */, 164 | ); 165 | }; 166 | /* End PBXProject section */ 167 | 168 | /* Begin PBXResourcesBuildPhase section */ 169 | 1B7529B61DDDE4BF002E9DE8 /* Resources */ = { 170 | isa = PBXResourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | 1B7529C61DDDE4BF002E9DE8 /* LaunchScreen.storyboard in Resources */, 174 | 1B7529C31DDDE4BF002E9DE8 /* Assets.xcassets in Resources */, 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | /* End PBXResourcesBuildPhase section */ 179 | 180 | /* Begin PBXSourcesBuildPhase section */ 181 | 1B7529B41DDDE4BF002E9DE8 /* Sources */ = { 182 | isa = PBXSourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 1B6869F11DDF0A1D006B134E /* Wireframe.swift in Sources */, 186 | 1B7529BC1DDDE4BF002E9DE8 /* AppDelegate.swift in Sources */, 187 | 1B7529D91DDDE59F002E9DE8 /* MainView.swift in Sources */, 188 | 1B7529D21DDDE51F002E9DE8 /* TextLoaderProtocol.swift in Sources */, 189 | 1B7529CF1DDDE4E8002E9DE8 /* MainViewController.swift in Sources */, 190 | 1B7529DB1DDDE5AA002E9DE8 /* MainViewProtocol.swift in Sources */, 191 | 1B7529D71DDDE56F002E9DE8 /* TextLoader.swift in Sources */, 192 | 1B7529D01DDDE4E8002E9DE8 /* DetailsViewController.swift in Sources */, 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | /* End PBXSourcesBuildPhase section */ 197 | 198 | /* Begin PBXVariantGroup section */ 199 | 1B7529C41DDDE4BF002E9DE8 /* LaunchScreen.storyboard */ = { 200 | isa = PBXVariantGroup; 201 | children = ( 202 | 1B7529C51DDDE4BF002E9DE8 /* Base */, 203 | ); 204 | name = LaunchScreen.storyboard; 205 | sourceTree = ""; 206 | }; 207 | /* End PBXVariantGroup section */ 208 | 209 | /* Begin XCBuildConfiguration section */ 210 | 1B7529C81DDDE4BF002E9DE8 /* Debug */ = { 211 | isa = XCBuildConfiguration; 212 | buildSettings = { 213 | ALWAYS_SEARCH_USER_PATHS = NO; 214 | CLANG_ANALYZER_NONNULL = YES; 215 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 216 | CLANG_CXX_LIBRARY = "libc++"; 217 | CLANG_ENABLE_MODULES = YES; 218 | CLANG_ENABLE_OBJC_ARC = YES; 219 | CLANG_WARN_BOOL_CONVERSION = YES; 220 | CLANG_WARN_CONSTANT_CONVERSION = YES; 221 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 222 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 223 | CLANG_WARN_EMPTY_BODY = YES; 224 | CLANG_WARN_ENUM_CONVERSION = YES; 225 | CLANG_WARN_INFINITE_RECURSION = YES; 226 | CLANG_WARN_INT_CONVERSION = YES; 227 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 228 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = dwarf; 234 | ENABLE_STRICT_OBJC_MSGSEND = YES; 235 | ENABLE_TESTABILITY = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_DYNAMIC_NO_PIC = NO; 238 | GCC_NO_COMMON_BLOCKS = YES; 239 | GCC_OPTIMIZATION_LEVEL = 0; 240 | GCC_PREPROCESSOR_DEFINITIONS = ( 241 | "DEBUG=1", 242 | "$(inherited)", 243 | ); 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 251 | MTL_ENABLE_DEBUG_INFO = YES; 252 | ONLY_ACTIVE_ARCH = YES; 253 | SDKROOT = iphoneos; 254 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 255 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 256 | }; 257 | name = Debug; 258 | }; 259 | 1B7529C91DDDE4BF002E9DE8 /* Release */ = { 260 | isa = XCBuildConfiguration; 261 | buildSettings = { 262 | ALWAYS_SEARCH_USER_PATHS = NO; 263 | CLANG_ANALYZER_NONNULL = YES; 264 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 265 | CLANG_CXX_LIBRARY = "libc++"; 266 | CLANG_ENABLE_MODULES = YES; 267 | CLANG_ENABLE_OBJC_ARC = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_CONSTANT_CONVERSION = YES; 270 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 271 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 272 | CLANG_WARN_EMPTY_BODY = YES; 273 | CLANG_WARN_ENUM_CONVERSION = YES; 274 | CLANG_WARN_INFINITE_RECURSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 277 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 278 | CLANG_WARN_UNREACHABLE_CODE = YES; 279 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 280 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 281 | COPY_PHASE_STRIP = NO; 282 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 283 | ENABLE_NS_ASSERTIONS = NO; 284 | ENABLE_STRICT_OBJC_MSGSEND = YES; 285 | GCC_C_LANGUAGE_STANDARD = gnu99; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 294 | MTL_ENABLE_DEBUG_INFO = NO; 295 | SDKROOT = iphoneos; 296 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 297 | VALIDATE_PRODUCT = YES; 298 | }; 299 | name = Release; 300 | }; 301 | 1B7529CB1DDDE4BF002E9DE8 /* Debug */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 305 | INFOPLIST_FILE = ControllerVC/Info.plist; 306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 307 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.ControllerVC; 308 | PRODUCT_NAME = "$(TARGET_NAME)"; 309 | SWIFT_VERSION = 3.0; 310 | }; 311 | name = Debug; 312 | }; 313 | 1B7529CC1DDDE4BF002E9DE8 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 317 | INFOPLIST_FILE = ControllerVC/Info.plist; 318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 319 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.ControllerVC; 320 | PRODUCT_NAME = "$(TARGET_NAME)"; 321 | SWIFT_VERSION = 3.0; 322 | }; 323 | name = Release; 324 | }; 325 | /* End XCBuildConfiguration section */ 326 | 327 | /* Begin XCConfigurationList section */ 328 | 1B7529B31DDDE4BF002E9DE8 /* Build configuration list for PBXProject "ControllerVC" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | 1B7529C81DDDE4BF002E9DE8 /* Debug */, 332 | 1B7529C91DDDE4BF002E9DE8 /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | 1B7529CA1DDDE4BF002E9DE8 /* Build configuration list for PBXNativeTarget "ControllerVC" */ = { 338 | isa = XCConfigurationList; 339 | buildConfigurations = ( 340 | 1B7529CB1DDDE4BF002E9DE8 /* Debug */, 341 | 1B7529CC1DDDE4BF002E9DE8 /* Release */, 342 | ); 343 | defaultConfigurationIsVisible = 0; 344 | defaultConfigurationName = Release; 345 | }; 346 | /* End XCConfigurationList section */ 347 | }; 348 | rootObject = 1B7529B01DDDE4BF002E9DE8 /* Project object */; 349 | } 350 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var wireframe: Wireframe? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | wireframe = Wireframe() 17 | 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/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 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/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 | 27 | 28 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController { 9 | 10 | 11 | private lazy var label = UILabel() 12 | 13 | private let text: String? 14 | 15 | init(text: String?) { 16 | self.text = text 17 | super.init(nibName: nil, bundle: nil) 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | title = "Details" 28 | 29 | view.backgroundColor = .white 30 | 31 | label.numberOfLines = 0 32 | label.text = text?.uppercased() 33 | view.addSubview(label) 34 | } 35 | 36 | override func viewDidLayoutSubviews() { 37 | super.viewDidLayoutSubviews() 38 | 39 | 40 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 41 | 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/MainView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainView: UIView, MainViewProtocol { 9 | private lazy var button = UIButton(type: .system) 10 | private lazy var label = UILabel() 11 | private lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 12 | 13 | weak var delegate: MainViewDelegate? 14 | 15 | init() { 16 | super.init(frame: CGRect()) 17 | backgroundColor = .white 18 | 19 | addSubview(activityIndicator) 20 | 21 | button.setTitle("Load", for: .normal) 22 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 23 | addSubview(button) 24 | 25 | label.numberOfLines = 0 26 | addSubview(label) 27 | } 28 | 29 | required init?(coder aDecoder: NSCoder) { 30 | fatalError("init(coder:) has not been implemented") 31 | } 32 | 33 | var text: String? { 34 | set { 35 | label.text = newValue 36 | } 37 | get { 38 | return label.text 39 | } 40 | } 41 | 42 | var loading: Bool { 43 | set { 44 | if newValue { 45 | activityIndicator.startAnimating() 46 | } else { 47 | activityIndicator.stopAnimating() 48 | } 49 | } 50 | 51 | get { 52 | return activityIndicator.isAnimating 53 | } 54 | } 55 | 56 | @objc private func buttonClicked() { 57 | delegate?.loadButtonClicked(view: self) 58 | } 59 | 60 | override func layoutSubviews() { 61 | super.layoutSubviews() 62 | 63 | activityIndicator.frame = bounds 64 | label.frame = UIEdgeInsetsInsetRect(bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 65 | button.frame = CGRect(x: 20, y: bounds.height - 60, width: bounds.width - 40, height: 40) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | protocol MainViewControllerRoutingDelegate: class { 9 | func showDetails(viewController: MainViewController) 10 | } 11 | 12 | class MainViewController: UIViewController { 13 | 14 | let textLoader: TextLoaderProtocol 15 | let rootView: MainViewProtocol 16 | 17 | weak var routingDelegate: MainViewControllerRoutingDelegate? 18 | 19 | init(textLoader: TextLoaderProtocol, rootView: MainViewProtocol) { 20 | self.textLoader = textLoader 21 | self.rootView = rootView 22 | 23 | super.init(nibName: nil, bundle: nil) 24 | 25 | title = "Controller VC" 26 | 27 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(detailsClicked)) 28 | navigationItem.rightBarButtonItem?.isEnabled = false 29 | } 30 | 31 | required init?(coder aDecoder: NSCoder) { 32 | fatalError("init(coder:) has not been implemented") 33 | } 34 | 35 | override func loadView() { 36 | view = rootView as? UIView 37 | } 38 | 39 | @objc private func detailsClicked() { 40 | 41 | routingDelegate?.showDetails(viewController: self) 42 | } 43 | } 44 | 45 | extension MainViewController: MainViewDelegate { 46 | func loadButtonClicked(view: MainViewProtocol) { 47 | rootView.loading = true 48 | rootView.text = nil 49 | 50 | navigationItem.rightBarButtonItem?.isEnabled = false 51 | 52 | textLoader.loadText { 53 | self.rootView.loading = false 54 | self.rootView.text = $0 55 | self.navigationItem.rightBarButtonItem?.isEnabled = true 56 | } 57 | } 58 | } 59 | 60 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/MainViewProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | protocol MainViewProtocol: class { 9 | var delegate: MainViewDelegate? {get set} 10 | var loading: Bool {get set} 11 | var text: String? {get set} 12 | } 13 | 14 | protocol MainViewDelegate: class { 15 | func loadButtonClicked(view: MainViewProtocol) 16 | } 17 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/TextLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class TextLoader: TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) { 10 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 11 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/TextLoaderProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) 10 | } 11 | -------------------------------------------------------------------------------- /2. ControllerVC/ControllerVC/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class Wireframe { 9 | 10 | let window: UIWindow 11 | let navigationController: UINavigationController 12 | init() { 13 | window = UIWindow(frame: UIScreen.main.bounds) 14 | 15 | let view = MainView() 16 | let vc = MainViewController(textLoader: TextLoader(), rootView: view) 17 | 18 | view.delegate = vc 19 | 20 | navigationController = UINavigationController(rootViewController: vc) 21 | window.rootViewController = navigationController 22 | window.makeKeyAndVisible() 23 | 24 | vc.routingDelegate = self 25 | } 26 | } 27 | 28 | extension Wireframe: MainViewControllerRoutingDelegate { 29 | 30 | func showDetails(viewController: MainViewController) { 31 | let vc = DetailsViewController(text: viewController.rootView.text) 32 | navigationController.pushViewController(vc, animated: true) 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1BD88B581DDEF1780059E401 /* TextLoaderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */; }; 11 | 1BD88B591DDEF1780059E401 /* TextLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B571DDEF1780059E401 /* TextLoader.swift */; }; 12 | 1BF815901DDE15EC00D7DDAB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8158F1DDE15EC00D7DDAB /* AppDelegate.swift */; }; 13 | 1BF815971DDE15EC00D7DDAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815961DDE15EC00D7DDAB /* Assets.xcassets */; }; 14 | 1BF8159A1DDE15EC00D7DDAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815981DDE15EC00D7DDAB /* LaunchScreen.storyboard */; }; 15 | 1BF815AE1DDE175700D7DDAB /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */; }; 16 | 1BF815B11DDE176C00D7DDAB /* MainViewControllerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */; }; 17 | 1BF815B51DDE185C00D7DDAB /* MainPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */; }; 18 | 1BF815B71DDE1F7D00D7DDAB /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */; }; 19 | 1BF815B91DDE217F00D7DDAB /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoaderProtocol.swift; sourceTree = ""; }; 24 | 1BD88B571DDEF1780059E401 /* TextLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoader.swift; sourceTree = ""; }; 25 | 1BF8158C1DDE15EC00D7DDAB /* VIPER.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VIPER.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 1BF8158F1DDE15EC00D7DDAB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 27 | 1BF815961DDE15EC00D7DDAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 1BF815991DDE15EC00D7DDAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 1BF8159B1DDE15EC00D7DDAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 31 | 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewControllerProtocol.swift; sourceTree = ""; }; 32 | 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainPresenter.swift; sourceTree = ""; }; 33 | 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = ""; }; 34 | 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 1BF815891DDE15EC00D7DDAB /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 1BF815831DDE15EC00D7DDAB = { 49 | isa = PBXGroup; 50 | children = ( 51 | 1BF8158E1DDE15EC00D7DDAB /* VIPER */, 52 | 1BF8158D1DDE15EC00D7DDAB /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 1BF8158D1DDE15EC00D7DDAB /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 1BF8158C1DDE15EC00D7DDAB /* VIPER.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | 1BF8158E1DDE15EC00D7DDAB /* VIPER */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 1BF815A41DDE165300D7DDAB /* View */, 68 | 1BF815A51DDE165900D7DDAB /* Model */, 69 | 1BF815A21DDE164400D7DDAB /* Presenter */, 70 | 1BF815A11DDE163F00D7DDAB /* Enitities aka Model */, 71 | 1BF815A31DDE164A00D7DDAB /* Routing */, 72 | 1BF8158F1DDE15EC00D7DDAB /* AppDelegate.swift */, 73 | 1BF815961DDE15EC00D7DDAB /* Assets.xcassets */, 74 | 1BF815981DDE15EC00D7DDAB /* LaunchScreen.storyboard */, 75 | 1BF8159B1DDE15EC00D7DDAB /* Info.plist */, 76 | ); 77 | path = VIPER; 78 | sourceTree = ""; 79 | }; 80 | 1BF815A11DDE163F00D7DDAB /* Enitities aka Model */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | ); 84 | name = "Enitities aka Model"; 85 | sourceTree = ""; 86 | }; 87 | 1BF815A21DDE164400D7DDAB /* Presenter */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */, 91 | ); 92 | name = Presenter; 93 | sourceTree = ""; 94 | }; 95 | 1BF815A31DDE164A00D7DDAB /* Routing */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */, 99 | ); 100 | name = Routing; 101 | sourceTree = ""; 102 | }; 103 | 1BF815A41DDE165300D7DDAB /* View */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */, 107 | 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */, 108 | 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */, 109 | ); 110 | name = View; 111 | sourceTree = ""; 112 | }; 113 | 1BF815A51DDE165900D7DDAB /* Model */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */, 117 | 1BD88B571DDEF1780059E401 /* TextLoader.swift */, 118 | ); 119 | name = Model; 120 | sourceTree = ""; 121 | }; 122 | /* End PBXGroup section */ 123 | 124 | /* Begin PBXNativeTarget section */ 125 | 1BF8158B1DDE15EC00D7DDAB /* VIPER */ = { 126 | isa = PBXNativeTarget; 127 | buildConfigurationList = 1BF8159E1DDE15EC00D7DDAB /* Build configuration list for PBXNativeTarget "VIPER" */; 128 | buildPhases = ( 129 | 1BF815881DDE15EC00D7DDAB /* Sources */, 130 | 1BF815891DDE15EC00D7DDAB /* Frameworks */, 131 | 1BF8158A1DDE15EC00D7DDAB /* Resources */, 132 | ); 133 | buildRules = ( 134 | ); 135 | dependencies = ( 136 | ); 137 | name = VIPER; 138 | productName = VIPER; 139 | productReference = 1BF8158C1DDE15EC00D7DDAB /* VIPER.app */; 140 | productType = "com.apple.product-type.application"; 141 | }; 142 | /* End PBXNativeTarget section */ 143 | 144 | /* Begin PBXProject section */ 145 | 1BF815841DDE15EC00D7DDAB /* Project object */ = { 146 | isa = PBXProject; 147 | attributes = { 148 | LastSwiftUpdateCheck = 0820; 149 | LastUpgradeCheck = 0820; 150 | ORGANIZATIONNAME = psharanda; 151 | TargetAttributes = { 152 | 1BF8158B1DDE15EC00D7DDAB = { 153 | CreatedOnToolsVersion = 8.2; 154 | ProvisioningStyle = Automatic; 155 | }; 156 | }; 157 | }; 158 | buildConfigurationList = 1BF815871DDE15EC00D7DDAB /* Build configuration list for PBXProject "VIPER" */; 159 | compatibilityVersion = "Xcode 3.2"; 160 | developmentRegion = English; 161 | hasScannedForEncodings = 0; 162 | knownRegions = ( 163 | en, 164 | Base, 165 | ); 166 | mainGroup = 1BF815831DDE15EC00D7DDAB; 167 | productRefGroup = 1BF8158D1DDE15EC00D7DDAB /* Products */; 168 | projectDirPath = ""; 169 | projectRoot = ""; 170 | targets = ( 171 | 1BF8158B1DDE15EC00D7DDAB /* VIPER */, 172 | ); 173 | }; 174 | /* End PBXProject section */ 175 | 176 | /* Begin PBXResourcesBuildPhase section */ 177 | 1BF8158A1DDE15EC00D7DDAB /* Resources */ = { 178 | isa = PBXResourcesBuildPhase; 179 | buildActionMask = 2147483647; 180 | files = ( 181 | 1BF8159A1DDE15EC00D7DDAB /* LaunchScreen.storyboard in Resources */, 182 | 1BF815971DDE15EC00D7DDAB /* Assets.xcassets in Resources */, 183 | ); 184 | runOnlyForDeploymentPostprocessing = 0; 185 | }; 186 | /* End PBXResourcesBuildPhase section */ 187 | 188 | /* Begin PBXSourcesBuildPhase section */ 189 | 1BF815881DDE15EC00D7DDAB /* Sources */ = { 190 | isa = PBXSourcesBuildPhase; 191 | buildActionMask = 2147483647; 192 | files = ( 193 | 1BF815B71DDE1F7D00D7DDAB /* Wireframe.swift in Sources */, 194 | 1BF815B91DDE217F00D7DDAB /* DetailsViewController.swift in Sources */, 195 | 1BF815901DDE15EC00D7DDAB /* AppDelegate.swift in Sources */, 196 | 1BF815B51DDE185C00D7DDAB /* MainPresenter.swift in Sources */, 197 | 1BD88B581DDEF1780059E401 /* TextLoaderProtocol.swift in Sources */, 198 | 1BF815B11DDE176C00D7DDAB /* MainViewControllerProtocol.swift in Sources */, 199 | 1BF815AE1DDE175700D7DDAB /* MainViewController.swift in Sources */, 200 | 1BD88B591DDEF1780059E401 /* TextLoader.swift in Sources */, 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | }; 204 | /* End PBXSourcesBuildPhase section */ 205 | 206 | /* Begin PBXVariantGroup section */ 207 | 1BF815981DDE15EC00D7DDAB /* LaunchScreen.storyboard */ = { 208 | isa = PBXVariantGroup; 209 | children = ( 210 | 1BF815991DDE15EC00D7DDAB /* Base */, 211 | ); 212 | name = LaunchScreen.storyboard; 213 | sourceTree = ""; 214 | }; 215 | /* End PBXVariantGroup section */ 216 | 217 | /* Begin XCBuildConfiguration section */ 218 | 1BF8159C1DDE15EC00D7DDAB /* Debug */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_ANALYZER_NONNULL = YES; 223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 224 | CLANG_CXX_LIBRARY = "libc++"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_WARN_BOOL_CONVERSION = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 230 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 231 | CLANG_WARN_EMPTY_BODY = YES; 232 | CLANG_WARN_ENUM_CONVERSION = YES; 233 | CLANG_WARN_INFINITE_RECURSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 236 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 237 | CLANG_WARN_UNREACHABLE_CODE = YES; 238 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 239 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 240 | COPY_PHASE_STRIP = NO; 241 | DEBUG_INFORMATION_FORMAT = dwarf; 242 | ENABLE_STRICT_OBJC_MSGSEND = YES; 243 | ENABLE_TESTABILITY = YES; 244 | GCC_C_LANGUAGE_STANDARD = gnu99; 245 | GCC_DYNAMIC_NO_PIC = NO; 246 | GCC_NO_COMMON_BLOCKS = YES; 247 | GCC_OPTIMIZATION_LEVEL = 0; 248 | GCC_PREPROCESSOR_DEFINITIONS = ( 249 | "DEBUG=1", 250 | "$(inherited)", 251 | ); 252 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 253 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 254 | GCC_WARN_UNDECLARED_SELECTOR = YES; 255 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 256 | GCC_WARN_UNUSED_FUNCTION = YES; 257 | GCC_WARN_UNUSED_VARIABLE = YES; 258 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 259 | MTL_ENABLE_DEBUG_INFO = YES; 260 | ONLY_ACTIVE_ARCH = YES; 261 | SDKROOT = iphoneos; 262 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 263 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 264 | }; 265 | name = Debug; 266 | }; 267 | 1BF8159D1DDE15EC00D7DDAB /* Release */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | ALWAYS_SEARCH_USER_PATHS = NO; 271 | CLANG_ANALYZER_NONNULL = YES; 272 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 273 | CLANG_CXX_LIBRARY = "libc++"; 274 | CLANG_ENABLE_MODULES = YES; 275 | CLANG_ENABLE_OBJC_ARC = YES; 276 | CLANG_WARN_BOOL_CONVERSION = YES; 277 | CLANG_WARN_CONSTANT_CONVERSION = YES; 278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 279 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 280 | CLANG_WARN_EMPTY_BODY = YES; 281 | CLANG_WARN_ENUM_CONVERSION = YES; 282 | CLANG_WARN_INFINITE_RECURSION = YES; 283 | CLANG_WARN_INT_CONVERSION = YES; 284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 285 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 286 | CLANG_WARN_UNREACHABLE_CODE = YES; 287 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 288 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 289 | COPY_PHASE_STRIP = NO; 290 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 291 | ENABLE_NS_ASSERTIONS = NO; 292 | ENABLE_STRICT_OBJC_MSGSEND = YES; 293 | GCC_C_LANGUAGE_STANDARD = gnu99; 294 | GCC_NO_COMMON_BLOCKS = YES; 295 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 296 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 297 | GCC_WARN_UNDECLARED_SELECTOR = YES; 298 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 299 | GCC_WARN_UNUSED_FUNCTION = YES; 300 | GCC_WARN_UNUSED_VARIABLE = YES; 301 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 302 | MTL_ENABLE_DEBUG_INFO = NO; 303 | SDKROOT = iphoneos; 304 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 305 | VALIDATE_PRODUCT = YES; 306 | }; 307 | name = Release; 308 | }; 309 | 1BF8159F1DDE15EC00D7DDAB /* Debug */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | INFOPLIST_FILE = VIPER/Info.plist; 314 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 315 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.VIPER; 316 | PRODUCT_NAME = "$(TARGET_NAME)"; 317 | SWIFT_VERSION = 3.0; 318 | }; 319 | name = Debug; 320 | }; 321 | 1BF815A01DDE15EC00D7DDAB /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 325 | INFOPLIST_FILE = VIPER/Info.plist; 326 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 327 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.VIPER; 328 | PRODUCT_NAME = "$(TARGET_NAME)"; 329 | SWIFT_VERSION = 3.0; 330 | }; 331 | name = Release; 332 | }; 333 | /* End XCBuildConfiguration section */ 334 | 335 | /* Begin XCConfigurationList section */ 336 | 1BF815871DDE15EC00D7DDAB /* Build configuration list for PBXProject "VIPER" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 1BF8159C1DDE15EC00D7DDAB /* Debug */, 340 | 1BF8159D1DDE15EC00D7DDAB /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | 1BF8159E1DDE15EC00D7DDAB /* Build configuration list for PBXNativeTarget "VIPER" */ = { 346 | isa = XCConfigurationList; 347 | buildConfigurations = ( 348 | 1BF8159F1DDE15EC00D7DDAB /* Debug */, 349 | 1BF815A01DDE15EC00D7DDAB /* Release */, 350 | ); 351 | defaultConfigurationIsVisible = 0; 352 | defaultConfigurationName = Release; 353 | }; 354 | /* End XCConfigurationList section */ 355 | }; 356 | rootObject = 1BF815841DDE15EC00D7DDAB /* Project object */; 357 | } 358 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var wireframe: Wireframe? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | wireframe = Wireframe() 17 | 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/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 | 27 | 28 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController { 9 | 10 | 11 | private lazy var label = UILabel() 12 | 13 | private let text: String? 14 | 15 | init(text: String?) { 16 | self.text = text 17 | super.init(nibName: nil, bundle: nil) 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | title = "Details" 28 | 29 | view.backgroundColor = .white 30 | 31 | label.numberOfLines = 0 32 | label.text = text?.uppercased() 33 | view.addSubview(label) 34 | } 35 | 36 | override func viewDidLayoutSubviews() { 37 | super.viewDidLayoutSubviews() 38 | 39 | 40 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 41 | 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/MainPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol MainPresenterRoutingDelegate: class { 9 | func showDetails(presenter: MainPresenter) 10 | } 11 | 12 | class MainPresenter { 13 | let textLoader: TextLoaderProtocol 14 | unowned let view: MainViewControllerProtocol 15 | weak var routingDelegate: MainPresenterRoutingDelegate? 16 | 17 | init(textLoader: TextLoaderProtocol, view: MainViewControllerProtocol) { 18 | self.textLoader = textLoader 19 | self.view = view 20 | 21 | self.view.delegate = self 22 | } 23 | } 24 | 25 | extension MainPresenter: MainViewControllerDelegate { 26 | 27 | func loadButtonClicked(view: MainViewControllerProtocol) { 28 | view.text = nil 29 | view.loading = true 30 | textLoader.loadText { 31 | view.loading = false 32 | view.text = $0 33 | } 34 | } 35 | 36 | func detailsClicked(view: MainViewControllerProtocol) { 37 | routingDelegate?.showDetails(presenter: self) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainViewController: UIViewController, MainViewControllerProtocol { 9 | 10 | var presenter: Any? 11 | 12 | private lazy var button = UIButton(type: .system) 13 | private lazy var label = UILabel() 14 | private lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 15 | 16 | 17 | weak var delegate: MainViewControllerDelegate? 18 | 19 | var text: String? { 20 | set { 21 | label.text = newValue 22 | navigationItem.rightBarButtonItem?.isEnabled = (newValue != nil) 23 | } 24 | get { 25 | return label.text 26 | } 27 | } 28 | 29 | var loading: Bool { 30 | set { 31 | if newValue { 32 | activityIndicator.startAnimating() 33 | } else { 34 | activityIndicator.stopAnimating() 35 | } 36 | } 37 | 38 | get { 39 | return activityIndicator.isAnimating 40 | } 41 | } 42 | 43 | override func viewDidLoad() { 44 | super.viewDidLoad() 45 | 46 | title = "VIPER" 47 | 48 | view.backgroundColor = .white 49 | 50 | view.addSubview(activityIndicator) 51 | 52 | button.setTitle("Load", for: .normal) 53 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 54 | view.addSubview(button) 55 | 56 | label.numberOfLines = 0 57 | view.addSubview(label) 58 | 59 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(detailsClicked)) 60 | navigationItem.rightBarButtonItem?.isEnabled = false 61 | } 62 | 63 | override func viewDidLayoutSubviews() { 64 | super.viewDidLayoutSubviews() 65 | 66 | activityIndicator.frame = view.bounds 67 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 68 | button.frame = CGRect(x: 20, y: view.bounds.height - 60, width: view.bounds.width - 40, height: 40) 69 | } 70 | 71 | @objc private func detailsClicked() { 72 | delegate?.detailsClicked(view: self) 73 | } 74 | 75 | @objc private func buttonClicked() { 76 | delegate?.loadButtonClicked(view: self) 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/MainViewControllerProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol MainViewControllerDelegate: class { 9 | func loadButtonClicked(view: MainViewControllerProtocol) 10 | func detailsClicked(view: MainViewControllerProtocol) 11 | } 12 | 13 | protocol MainViewControllerProtocol: class { 14 | var delegate: MainViewControllerDelegate? {get set} 15 | var loading: Bool {get set} 16 | var text: String? {get set} 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/TextLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class TextLoader: TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) { 10 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 11 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/TextLoaderProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) 10 | } 11 | -------------------------------------------------------------------------------- /3. VIPER aka MVP+Routing/VIPER/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class Wireframe { 9 | 10 | let window: UIWindow 11 | let navigationController: UINavigationController 12 | init() { 13 | window = UIWindow(frame: UIScreen.main.bounds) 14 | 15 | let vc = MainViewController() 16 | 17 | let presenter = MainPresenter(textLoader: TextLoader(), view: vc) 18 | 19 | vc.presenter = presenter 20 | 21 | navigationController = UINavigationController(rootViewController: vc) 22 | window.rootViewController = navigationController 23 | window.makeKeyAndVisible() 24 | 25 | presenter.routingDelegate = self 26 | } 27 | } 28 | 29 | extension Wireframe: MainPresenterRoutingDelegate { 30 | func showDetails(presenter: MainPresenter) { 31 | let vc = DetailsViewController(text: presenter.view.text) 32 | navigationController.pushViewController(vc, animated: true) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /4. MVVM/MVVM.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1BD88B5B1DDEFAA80059E401 /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B5A1DDEFAA80059E401 /* Wireframe.swift */; }; 11 | 1BF8155D1DDE0C0800D7DDAB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8155C1DDE0C0800D7DDAB /* AppDelegate.swift */; }; 12 | 1BF815641DDE0C0800D7DDAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815631DDE0C0800D7DDAB /* Assets.xcassets */; }; 13 | 1BF815671DDE0C0800D7DDAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815651DDE0C0800D7DDAB /* LaunchScreen.storyboard */; }; 14 | 1BF815731DDE0CB600D7DDAB /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815711DDE0CB600D7DDAB /* DetailsViewController.swift */; }; 15 | 1BF815741DDE0CB600D7DDAB /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815721DDE0CB600D7DDAB /* MainViewController.swift */; }; 16 | 1BF815781DDE0CDB00D7DDAB /* MainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815771DDE0CDB00D7DDAB /* MainViewModel.swift */; }; 17 | 1BF8157A1DDE0CF200D7DDAB /* MainViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815791DDE0CF200D7DDAB /* MainViewModelProtocol.swift */; }; 18 | 1BF815811DDE0EA800D7DDAB /* TextLoaderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8157F1DDE0EA800D7DDAB /* TextLoaderProtocol.swift */; }; 19 | 1BF815821DDE0EA800D7DDAB /* TextLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815801DDE0EA800D7DDAB /* TextLoader.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 1BD88B5A1DDEFAA80059E401 /* Wireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = ""; }; 24 | 1BF815591DDE0C0800D7DDAB /* MVVM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MVVM.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 1BF8155C1DDE0C0800D7DDAB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | 1BF815631DDE0C0800D7DDAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | 1BF815661DDE0C0800D7DDAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | 1BF815681DDE0C0800D7DDAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | 1BF815711DDE0CB600D7DDAB /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = ""; }; 30 | 1BF815721DDE0CB600D7DDAB /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 31 | 1BF815771DDE0CDB00D7DDAB /* MainViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewModel.swift; sourceTree = ""; }; 32 | 1BF815791DDE0CF200D7DDAB /* MainViewModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewModelProtocol.swift; sourceTree = ""; }; 33 | 1BF8157F1DDE0EA800D7DDAB /* TextLoaderProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoaderProtocol.swift; sourceTree = ""; }; 34 | 1BF815801DDE0EA800D7DDAB /* TextLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoader.swift; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 1BF815561DDE0C0800D7DDAB /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | 1BD88B5C1DDEFAAA0059E401 /* Routing */ = { 49 | isa = PBXGroup; 50 | children = ( 51 | 1BD88B5A1DDEFAA80059E401 /* Wireframe.swift */, 52 | ); 53 | name = Routing; 54 | sourceTree = ""; 55 | }; 56 | 1BF815501DDE0C0800D7DDAB = { 57 | isa = PBXGroup; 58 | children = ( 59 | 1BF8155B1DDE0C0800D7DDAB /* MVVM */, 60 | 1BF8155A1DDE0C0800D7DDAB /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 1BF8155A1DDE0C0800D7DDAB /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 1BF815591DDE0C0800D7DDAB /* MVVM.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 1BF8155B1DDE0C0800D7DDAB /* MVVM */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 1BF8156E1DDE0C3D00D7DDAB /* Model */, 76 | 1BF8156F1DDE0C4200D7DDAB /* View */, 77 | 1BF815701DDE0C4900D7DDAB /* ViewModel */, 78 | 1BD88B5C1DDEFAAA0059E401 /* Routing */, 79 | 1BF8155C1DDE0C0800D7DDAB /* AppDelegate.swift */, 80 | 1BF815631DDE0C0800D7DDAB /* Assets.xcassets */, 81 | 1BF815651DDE0C0800D7DDAB /* LaunchScreen.storyboard */, 82 | 1BF815681DDE0C0800D7DDAB /* Info.plist */, 83 | ); 84 | path = MVVM; 85 | sourceTree = ""; 86 | }; 87 | 1BF8156E1DDE0C3D00D7DDAB /* Model */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 1BF8157F1DDE0EA800D7DDAB /* TextLoaderProtocol.swift */, 91 | 1BF815801DDE0EA800D7DDAB /* TextLoader.swift */, 92 | ); 93 | name = Model; 94 | sourceTree = ""; 95 | }; 96 | 1BF8156F1DDE0C4200D7DDAB /* View */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 1BF815721DDE0CB600D7DDAB /* MainViewController.swift */, 100 | 1BF815711DDE0CB600D7DDAB /* DetailsViewController.swift */, 101 | ); 102 | name = View; 103 | sourceTree = ""; 104 | }; 105 | 1BF815701DDE0C4900D7DDAB /* ViewModel */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 1BF815791DDE0CF200D7DDAB /* MainViewModelProtocol.swift */, 109 | 1BF815771DDE0CDB00D7DDAB /* MainViewModel.swift */, 110 | ); 111 | name = ViewModel; 112 | sourceTree = ""; 113 | }; 114 | /* End PBXGroup section */ 115 | 116 | /* Begin PBXNativeTarget section */ 117 | 1BF815581DDE0C0800D7DDAB /* MVVM */ = { 118 | isa = PBXNativeTarget; 119 | buildConfigurationList = 1BF8156B1DDE0C0800D7DDAB /* Build configuration list for PBXNativeTarget "MVVM" */; 120 | buildPhases = ( 121 | 1BF815551DDE0C0800D7DDAB /* Sources */, 122 | 1BF815561DDE0C0800D7DDAB /* Frameworks */, 123 | 1BF815571DDE0C0800D7DDAB /* Resources */, 124 | ); 125 | buildRules = ( 126 | ); 127 | dependencies = ( 128 | ); 129 | name = MVVM; 130 | productName = MVVM; 131 | productReference = 1BF815591DDE0C0800D7DDAB /* MVVM.app */; 132 | productType = "com.apple.product-type.application"; 133 | }; 134 | /* End PBXNativeTarget section */ 135 | 136 | /* Begin PBXProject section */ 137 | 1BF815511DDE0C0800D7DDAB /* Project object */ = { 138 | isa = PBXProject; 139 | attributes = { 140 | LastSwiftUpdateCheck = 0820; 141 | LastUpgradeCheck = 0820; 142 | ORGANIZATIONNAME = psharanda; 143 | TargetAttributes = { 144 | 1BF815581DDE0C0800D7DDAB = { 145 | CreatedOnToolsVersion = 8.2; 146 | ProvisioningStyle = Automatic; 147 | }; 148 | }; 149 | }; 150 | buildConfigurationList = 1BF815541DDE0C0800D7DDAB /* Build configuration list for PBXProject "MVVM" */; 151 | compatibilityVersion = "Xcode 3.2"; 152 | developmentRegion = English; 153 | hasScannedForEncodings = 0; 154 | knownRegions = ( 155 | en, 156 | Base, 157 | ); 158 | mainGroup = 1BF815501DDE0C0800D7DDAB; 159 | productRefGroup = 1BF8155A1DDE0C0800D7DDAB /* Products */; 160 | projectDirPath = ""; 161 | projectRoot = ""; 162 | targets = ( 163 | 1BF815581DDE0C0800D7DDAB /* MVVM */, 164 | ); 165 | }; 166 | /* End PBXProject section */ 167 | 168 | /* Begin PBXResourcesBuildPhase section */ 169 | 1BF815571DDE0C0800D7DDAB /* Resources */ = { 170 | isa = PBXResourcesBuildPhase; 171 | buildActionMask = 2147483647; 172 | files = ( 173 | 1BF815671DDE0C0800D7DDAB /* LaunchScreen.storyboard in Resources */, 174 | 1BF815641DDE0C0800D7DDAB /* Assets.xcassets in Resources */, 175 | ); 176 | runOnlyForDeploymentPostprocessing = 0; 177 | }; 178 | /* End PBXResourcesBuildPhase section */ 179 | 180 | /* Begin PBXSourcesBuildPhase section */ 181 | 1BF815551DDE0C0800D7DDAB /* Sources */ = { 182 | isa = PBXSourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 1BF815781DDE0CDB00D7DDAB /* MainViewModel.swift in Sources */, 186 | 1BF815741DDE0CB600D7DDAB /* MainViewController.swift in Sources */, 187 | 1BF815821DDE0EA800D7DDAB /* TextLoader.swift in Sources */, 188 | 1BF8155D1DDE0C0800D7DDAB /* AppDelegate.swift in Sources */, 189 | 1BD88B5B1DDEFAA80059E401 /* Wireframe.swift in Sources */, 190 | 1BF815811DDE0EA800D7DDAB /* TextLoaderProtocol.swift in Sources */, 191 | 1BF8157A1DDE0CF200D7DDAB /* MainViewModelProtocol.swift in Sources */, 192 | 1BF815731DDE0CB600D7DDAB /* DetailsViewController.swift in Sources */, 193 | ); 194 | runOnlyForDeploymentPostprocessing = 0; 195 | }; 196 | /* End PBXSourcesBuildPhase section */ 197 | 198 | /* Begin PBXVariantGroup section */ 199 | 1BF815651DDE0C0800D7DDAB /* LaunchScreen.storyboard */ = { 200 | isa = PBXVariantGroup; 201 | children = ( 202 | 1BF815661DDE0C0800D7DDAB /* Base */, 203 | ); 204 | name = LaunchScreen.storyboard; 205 | sourceTree = ""; 206 | }; 207 | /* End PBXVariantGroup section */ 208 | 209 | /* Begin XCBuildConfiguration section */ 210 | 1BF815691DDE0C0800D7DDAB /* Debug */ = { 211 | isa = XCBuildConfiguration; 212 | buildSettings = { 213 | ALWAYS_SEARCH_USER_PATHS = NO; 214 | CLANG_ANALYZER_NONNULL = YES; 215 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 216 | CLANG_CXX_LIBRARY = "libc++"; 217 | CLANG_ENABLE_MODULES = YES; 218 | CLANG_ENABLE_OBJC_ARC = YES; 219 | CLANG_WARN_BOOL_CONVERSION = YES; 220 | CLANG_WARN_CONSTANT_CONVERSION = YES; 221 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 222 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 223 | CLANG_WARN_EMPTY_BODY = YES; 224 | CLANG_WARN_ENUM_CONVERSION = YES; 225 | CLANG_WARN_INFINITE_RECURSION = YES; 226 | CLANG_WARN_INT_CONVERSION = YES; 227 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 228 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 229 | CLANG_WARN_UNREACHABLE_CODE = YES; 230 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 231 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 232 | COPY_PHASE_STRIP = NO; 233 | DEBUG_INFORMATION_FORMAT = dwarf; 234 | ENABLE_STRICT_OBJC_MSGSEND = YES; 235 | ENABLE_TESTABILITY = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_DYNAMIC_NO_PIC = NO; 238 | GCC_NO_COMMON_BLOCKS = YES; 239 | GCC_OPTIMIZATION_LEVEL = 0; 240 | GCC_PREPROCESSOR_DEFINITIONS = ( 241 | "DEBUG=1", 242 | "$(inherited)", 243 | ); 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 251 | MTL_ENABLE_DEBUG_INFO = YES; 252 | ONLY_ACTIVE_ARCH = YES; 253 | SDKROOT = iphoneos; 254 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 255 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 256 | }; 257 | name = Debug; 258 | }; 259 | 1BF8156A1DDE0C0800D7DDAB /* Release */ = { 260 | isa = XCBuildConfiguration; 261 | buildSettings = { 262 | ALWAYS_SEARCH_USER_PATHS = NO; 263 | CLANG_ANALYZER_NONNULL = YES; 264 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 265 | CLANG_CXX_LIBRARY = "libc++"; 266 | CLANG_ENABLE_MODULES = YES; 267 | CLANG_ENABLE_OBJC_ARC = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_CONSTANT_CONVERSION = YES; 270 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 271 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 272 | CLANG_WARN_EMPTY_BODY = YES; 273 | CLANG_WARN_ENUM_CONVERSION = YES; 274 | CLANG_WARN_INFINITE_RECURSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 277 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 278 | CLANG_WARN_UNREACHABLE_CODE = YES; 279 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 280 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 281 | COPY_PHASE_STRIP = NO; 282 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 283 | ENABLE_NS_ASSERTIONS = NO; 284 | ENABLE_STRICT_OBJC_MSGSEND = YES; 285 | GCC_C_LANGUAGE_STANDARD = gnu99; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 294 | MTL_ENABLE_DEBUG_INFO = NO; 295 | SDKROOT = iphoneos; 296 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 297 | VALIDATE_PRODUCT = YES; 298 | }; 299 | name = Release; 300 | }; 301 | 1BF8156C1DDE0C0800D7DDAB /* Debug */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 305 | INFOPLIST_FILE = MVVM/Info.plist; 306 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 307 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.MVVM; 308 | PRODUCT_NAME = "$(TARGET_NAME)"; 309 | SWIFT_VERSION = 3.0; 310 | }; 311 | name = Debug; 312 | }; 313 | 1BF8156D1DDE0C0800D7DDAB /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 317 | INFOPLIST_FILE = MVVM/Info.plist; 318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 319 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.MVVM; 320 | PRODUCT_NAME = "$(TARGET_NAME)"; 321 | SWIFT_VERSION = 3.0; 322 | }; 323 | name = Release; 324 | }; 325 | /* End XCBuildConfiguration section */ 326 | 327 | /* Begin XCConfigurationList section */ 328 | 1BF815541DDE0C0800D7DDAB /* Build configuration list for PBXProject "MVVM" */ = { 329 | isa = XCConfigurationList; 330 | buildConfigurations = ( 331 | 1BF815691DDE0C0800D7DDAB /* Debug */, 332 | 1BF8156A1DDE0C0800D7DDAB /* Release */, 333 | ); 334 | defaultConfigurationIsVisible = 0; 335 | defaultConfigurationName = Release; 336 | }; 337 | 1BF8156B1DDE0C0800D7DDAB /* Build configuration list for PBXNativeTarget "MVVM" */ = { 338 | isa = XCConfigurationList; 339 | buildConfigurations = ( 340 | 1BF8156C1DDE0C0800D7DDAB /* Debug */, 341 | 1BF8156D1DDE0C0800D7DDAB /* Release */, 342 | ); 343 | defaultConfigurationIsVisible = 0; 344 | defaultConfigurationName = Release; 345 | }; 346 | /* End XCConfigurationList section */ 347 | }; 348 | rootObject = 1BF815511DDE0C0800D7DDAB /* Project object */; 349 | } 350 | -------------------------------------------------------------------------------- /4. MVVM/MVVM.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var wireframe: Wireframe? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | wireframe = Wireframe() 17 | 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /4. MVVM/MVVM/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 | 27 | 28 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController { 9 | 10 | private lazy var label = UILabel() 11 | 12 | private let text: String? 13 | 14 | init(text: String?) { 15 | self.text = text 16 | super.init(nibName: nil, bundle: nil) 17 | } 18 | 19 | required init?(coder aDecoder: NSCoder) { 20 | fatalError("init(coder:) has not been implemented") 21 | } 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | title = "Details" 27 | 28 | view.backgroundColor = .white 29 | 30 | label.numberOfLines = 0 31 | label.text = text?.uppercased() 32 | view.addSubview(label) 33 | } 34 | 35 | override func viewDidLayoutSubviews() { 36 | super.viewDidLayoutSubviews() 37 | 38 | 39 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainViewController: UIViewController { 9 | 10 | fileprivate lazy var button = UIButton(type: .system) 11 | fileprivate lazy var label = UILabel() 12 | fileprivate lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 13 | 14 | let viewModel: MainViewModelProtocol 15 | 16 | init(viewModel: MainViewModelProtocol) { 17 | self.viewModel = viewModel 18 | super.init(nibName: nil, bundle: nil) 19 | } 20 | 21 | @objc private func doneClicked() { 22 | viewModel.detailsClicked() 23 | } 24 | 25 | @objc private func buttonClicked() { 26 | viewModel.loadButtonClicked() 27 | } 28 | 29 | required init?(coder aDecoder: NSCoder) { 30 | fatalError() 31 | } 32 | 33 | override func viewDidLoad() { 34 | super.viewDidLoad() 35 | 36 | title = "MVVM" 37 | 38 | view.backgroundColor = .white 39 | 40 | view.addSubview(activityIndicator) 41 | 42 | button.setTitle("Load", for: .normal) 43 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 44 | view.addSubview(button) 45 | 46 | label.numberOfLines = 0 47 | view.addSubview(label) 48 | 49 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(doneClicked)) 50 | navigationItem.rightBarButtonItem?.isEnabled = false 51 | 52 | loadingWasChanged(viewModel: viewModel) 53 | textWasChanged(viewModel: viewModel) 54 | } 55 | 56 | override func viewDidLayoutSubviews() { 57 | super.viewDidLayoutSubviews() 58 | 59 | activityIndicator.frame = view.bounds 60 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 61 | button.frame = CGRect(x: 20, y: view.bounds.height - 60, width: view.bounds.width - 40, height: 40) 62 | } 63 | 64 | 65 | } 66 | 67 | extension MainViewController: MainViewModelDelegate { 68 | 69 | func loadingWasChanged(viewModel: MainViewModelProtocol) { 70 | if viewModel.loading { 71 | activityIndicator.startAnimating() 72 | } else { 73 | activityIndicator.stopAnimating() 74 | } 75 | } 76 | 77 | func textWasChanged(viewModel: MainViewModelProtocol) { 78 | label.text = viewModel.text 79 | navigationItem.rightBarButtonItem?.isEnabled = (viewModel.text != nil) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/MainViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class MainViewModel: MainViewModelProtocol { 9 | 10 | weak var delegate: MainViewModelDelegate? 11 | weak var routingDelegate: MainViewModelRoutingDelegate? 12 | 13 | var loading: Bool = false { 14 | didSet { 15 | delegate?.loadingWasChanged(viewModel: self) 16 | } 17 | } 18 | 19 | var text: String? { 20 | didSet { 21 | delegate?.textWasChanged(viewModel: self) 22 | } 23 | } 24 | 25 | let textLoader: TextLoaderProtocol 26 | 27 | init(textLoader: TextLoaderProtocol) { 28 | self.textLoader = textLoader 29 | } 30 | 31 | func loadButtonClicked() { 32 | loading = true 33 | text = nil 34 | self.textLoader.loadText { 35 | self.loading = false 36 | self.text = $0 37 | } 38 | } 39 | 40 | func detailsClicked() { 41 | routingDelegate?.showDetails(viewModel: self) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/MainViewModelProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol MainViewModelDelegate: class { 9 | func loadingWasChanged(viewModel: MainViewModelProtocol) 10 | func textWasChanged(viewModel: MainViewModelProtocol) 11 | } 12 | 13 | protocol MainViewModelRoutingDelegate: class { 14 | func showDetails(viewModel: MainViewModelProtocol) 15 | } 16 | 17 | protocol MainViewModelProtocol { 18 | var delegate: MainViewModelDelegate? {get set} 19 | var routingDelegate: MainViewModelRoutingDelegate? {get set} 20 | var loading: Bool {get} 21 | var text: String? {get} 22 | func loadButtonClicked() 23 | func detailsClicked() 24 | } 25 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/TextLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class TextLoader: TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) { 10 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 11 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/TextLoaderProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) 10 | } 11 | -------------------------------------------------------------------------------- /4. MVVM/MVVM/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class Wireframe { 9 | 10 | let window: UIWindow 11 | let navigationController: UINavigationController 12 | init() { 13 | window = UIWindow(frame: UIScreen.main.bounds) 14 | 15 | let viewModel = MainViewModel(textLoader: TextLoader()) 16 | let vc = MainViewController(viewModel: viewModel) 17 | 18 | viewModel.delegate = vc 19 | 20 | navigationController = UINavigationController(rootViewController: vc) 21 | window.rootViewController = navigationController 22 | window.makeKeyAndVisible() 23 | 24 | viewModel.routingDelegate = self 25 | } 26 | } 27 | 28 | extension Wireframe: MainViewModelRoutingDelegate { 29 | 30 | func showDetails(viewModel: MainViewModelProtocol) { 31 | let vc = DetailsViewController(text: viewModel.text) 32 | navigationController.pushViewController(vc, animated: true) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B158F6E1DDF21150069E60E /* Signal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B158F6D1DDF21150069E60E /* Signal.swift */; }; 11 | 1B45810E1DE1D6F1003F96A2 /* MainModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B45810D1DE1D6F1003F96A2 /* MainModule.swift */; }; 12 | 1B4581121DE1DBDE003F96A2 /* Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B4581111DE1DBDE003F96A2 /* Context.swift */; }; 13 | 1B4581141DE1E47B003F96A2 /* Routing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B4581131DE1E47B003F96A2 /* Routing.swift */; }; 14 | 1B6050321DE201DE00B74DC3 /* Context.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B4581111DE1DBDE003F96A2 /* Context.swift */; }; 15 | 1B6050331DE201DE00B74DC3 /* Routing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B4581131DE1E47B003F96A2 /* Routing.swift */; }; 16 | 1B6050341DE201DE00B74DC3 /* MainViewControllerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */; }; 17 | 1B6050351DE201DE00B74DC3 /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */; }; 18 | 1B6050361DE201DE00B74DC3 /* MainPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */; }; 19 | 1B6050371DE201DE00B74DC3 /* MainModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B45810D1DE1D6F1003F96A2 /* MainModule.swift */; }; 20 | 1B6050381DE201DE00B74DC3 /* Signal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B158F6D1DDF21150069E60E /* Signal.swift */; }; 21 | 1B6050391DE201DE00B74DC3 /* TextLoaderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */; }; 22 | 1B60503A1DE201DE00B74DC3 /* TextLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B571DDEF1780059E401 /* TextLoader.swift */; }; 23 | 1B60503B1DE201DE00B74DC3 /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */; }; 24 | 1B60503C1DE201DE00B74DC3 /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */; }; 25 | 1B60503E1DE201F200B74DC3 /* TestContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B60503D1DE201F200B74DC3 /* TestContext.swift */; }; 26 | 1B6050401DE206CD00B74DC3 /* VIPERTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B60501F1DE1FF3900B74DC3 /* VIPERTests.swift */; }; 27 | 1BD88B581DDEF1780059E401 /* TextLoaderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */; }; 28 | 1BD88B591DDEF1780059E401 /* TextLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BD88B571DDEF1780059E401 /* TextLoader.swift */; }; 29 | 1BF815901DDE15EC00D7DDAB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8158F1DDE15EC00D7DDAB /* AppDelegate.swift */; }; 30 | 1BF815971DDE15EC00D7DDAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815961DDE15EC00D7DDAB /* Assets.xcassets */; }; 31 | 1BF8159A1DDE15EC00D7DDAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815981DDE15EC00D7DDAB /* LaunchScreen.storyboard */; }; 32 | 1BF815AE1DDE175700D7DDAB /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */; }; 33 | 1BF815B11DDE176C00D7DDAB /* MainViewControllerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */; }; 34 | 1BF815B51DDE185C00D7DDAB /* MainPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */; }; 35 | 1BF815B71DDE1F7D00D7DDAB /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */; }; 36 | 1BF815B91DDE217F00D7DDAB /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXContainerItemProxy section */ 40 | 1B6050221DE1FF3900B74DC3 /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = 1BF815841DDE15EC00D7DDAB /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = 1BF8158B1DDE15EC00D7DDAB; 45 | remoteInfo = VIPER; 46 | }; 47 | /* End PBXContainerItemProxy section */ 48 | 49 | /* Begin PBXFileReference section */ 50 | 1B158F6D1DDF21150069E60E /* Signal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Signal.swift; sourceTree = ""; }; 51 | 1B45810D1DE1D6F1003F96A2 /* MainModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainModule.swift; sourceTree = ""; }; 52 | 1B4581111DE1DBDE003F96A2 /* Context.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Context.swift; sourceTree = ""; }; 53 | 1B4581131DE1E47B003F96A2 /* Routing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Routing.swift; sourceTree = ""; }; 54 | 1B60501D1DE1FF3900B74DC3 /* VIPERTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VIPERTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 1B60501F1DE1FF3900B74DC3 /* VIPERTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VIPERTests.swift; sourceTree = ""; }; 56 | 1B6050211DE1FF3900B74DC3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 57 | 1B60503D1DE201F200B74DC3 /* TestContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestContext.swift; sourceTree = ""; }; 58 | 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoaderProtocol.swift; sourceTree = ""; }; 59 | 1BD88B571DDEF1780059E401 /* TextLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoader.swift; sourceTree = ""; }; 60 | 1BF8158C1DDE15EC00D7DDAB /* VIPER.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VIPER.app; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | 1BF8158F1DDE15EC00D7DDAB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 62 | 1BF815961DDE15EC00D7DDAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 63 | 1BF815991DDE15EC00D7DDAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 64 | 1BF8159B1DDE15EC00D7DDAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65 | 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 66 | 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewControllerProtocol.swift; sourceTree = ""; }; 67 | 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainPresenter.swift; sourceTree = ""; }; 68 | 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = ""; }; 69 | 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = ""; }; 70 | /* End PBXFileReference section */ 71 | 72 | /* Begin PBXFrameworksBuildPhase section */ 73 | 1B60501A1DE1FF3900B74DC3 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | 1BF815891DDE15EC00D7DDAB /* Frameworks */ = { 81 | isa = PBXFrameworksBuildPhase; 82 | buildActionMask = 2147483647; 83 | files = ( 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | 1B45810A1DE1D67E003F96A2 /* Module */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 1B45810D1DE1D6F1003F96A2 /* MainModule.swift */, 94 | 1BF815B01DDE176C00D7DDAB /* MainViewControllerProtocol.swift */, 95 | 1BF815B41DDE185C00D7DDAB /* MainPresenter.swift */, 96 | 1BF815AC1DDE175700D7DDAB /* MainViewController.swift */, 97 | ); 98 | name = Module; 99 | sourceTree = ""; 100 | }; 101 | 1B60501E1DE1FF3900B74DC3 /* VIPERTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 1B60501F1DE1FF3900B74DC3 /* VIPERTests.swift */, 105 | 1B6050211DE1FF3900B74DC3 /* Info.plist */, 106 | 1B60503D1DE201F200B74DC3 /* TestContext.swift */, 107 | ); 108 | path = VIPERTests; 109 | sourceTree = ""; 110 | }; 111 | 1BF815831DDE15EC00D7DDAB = { 112 | isa = PBXGroup; 113 | children = ( 114 | 1BF8158E1DDE15EC00D7DDAB /* VIPER */, 115 | 1B60501E1DE1FF3900B74DC3 /* VIPERTests */, 116 | 1BF8158D1DDE15EC00D7DDAB /* Products */, 117 | ); 118 | sourceTree = ""; 119 | }; 120 | 1BF8158D1DDE15EC00D7DDAB /* Products */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 1BF8158C1DDE15EC00D7DDAB /* VIPER.app */, 124 | 1B60501D1DE1FF3900B74DC3 /* VIPERTests.xctest */, 125 | ); 126 | name = Products; 127 | sourceTree = ""; 128 | }; 129 | 1BF8158E1DDE15EC00D7DDAB /* VIPER */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 1B4581111DE1DBDE003F96A2 /* Context.swift */, 133 | 1B4581131DE1E47B003F96A2 /* Routing.swift */, 134 | 1B45810A1DE1D67E003F96A2 /* Module */, 135 | 1B158F6D1DDF21150069E60E /* Signal.swift */, 136 | 1BF815A51DDE165900D7DDAB /* Model */, 137 | 1BF815A41DDE165300D7DDAB /* View */, 138 | 1BF815A21DDE164400D7DDAB /* Presenter */, 139 | 1BF815A31DDE164A00D7DDAB /* Routing */, 140 | 1BF8158F1DDE15EC00D7DDAB /* AppDelegate.swift */, 141 | 1BF815961DDE15EC00D7DDAB /* Assets.xcassets */, 142 | 1BF815981DDE15EC00D7DDAB /* LaunchScreen.storyboard */, 143 | 1BF8159B1DDE15EC00D7DDAB /* Info.plist */, 144 | ); 145 | path = VIPER; 146 | sourceTree = ""; 147 | }; 148 | 1BF815A21DDE164400D7DDAB /* Presenter */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | ); 152 | name = Presenter; 153 | sourceTree = ""; 154 | }; 155 | 1BF815A31DDE164A00D7DDAB /* Routing */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 1BF815B61DDE1F7D00D7DDAB /* Wireframe.swift */, 159 | ); 160 | name = Routing; 161 | sourceTree = ""; 162 | }; 163 | 1BF815A41DDE165300D7DDAB /* View */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | 1BF815B81DDE217F00D7DDAB /* DetailsViewController.swift */, 167 | ); 168 | name = View; 169 | sourceTree = ""; 170 | }; 171 | 1BF815A51DDE165900D7DDAB /* Model */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | 1BD88B561DDEF1780059E401 /* TextLoaderProtocol.swift */, 175 | 1BD88B571DDEF1780059E401 /* TextLoader.swift */, 176 | ); 177 | name = Model; 178 | sourceTree = ""; 179 | }; 180 | /* End PBXGroup section */ 181 | 182 | /* Begin PBXNativeTarget section */ 183 | 1B60501C1DE1FF3900B74DC3 /* VIPERTests */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = 1B6050261DE1FF3900B74DC3 /* Build configuration list for PBXNativeTarget "VIPERTests" */; 186 | buildPhases = ( 187 | 1B6050191DE1FF3900B74DC3 /* Sources */, 188 | 1B60501A1DE1FF3900B74DC3 /* Frameworks */, 189 | 1B60501B1DE1FF3900B74DC3 /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | 1B6050231DE1FF3900B74DC3 /* PBXTargetDependency */, 195 | ); 196 | name = VIPERTests; 197 | productName = VIPERTests; 198 | productReference = 1B60501D1DE1FF3900B74DC3 /* VIPERTests.xctest */; 199 | productType = "com.apple.product-type.bundle.unit-test"; 200 | }; 201 | 1BF8158B1DDE15EC00D7DDAB /* VIPER */ = { 202 | isa = PBXNativeTarget; 203 | buildConfigurationList = 1BF8159E1DDE15EC00D7DDAB /* Build configuration list for PBXNativeTarget "VIPER" */; 204 | buildPhases = ( 205 | 1BF815881DDE15EC00D7DDAB /* Sources */, 206 | 1BF815891DDE15EC00D7DDAB /* Frameworks */, 207 | 1BF8158A1DDE15EC00D7DDAB /* Resources */, 208 | ); 209 | buildRules = ( 210 | ); 211 | dependencies = ( 212 | ); 213 | name = VIPER; 214 | productName = VIPER; 215 | productReference = 1BF8158C1DDE15EC00D7DDAB /* VIPER.app */; 216 | productType = "com.apple.product-type.application"; 217 | }; 218 | /* End PBXNativeTarget section */ 219 | 220 | /* Begin PBXProject section */ 221 | 1BF815841DDE15EC00D7DDAB /* Project object */ = { 222 | isa = PBXProject; 223 | attributes = { 224 | LastSwiftUpdateCheck = 0820; 225 | LastUpgradeCheck = 0820; 226 | ORGANIZATIONNAME = psharanda; 227 | TargetAttributes = { 228 | 1B60501C1DE1FF3900B74DC3 = { 229 | CreatedOnToolsVersion = 8.2; 230 | ProvisioningStyle = Automatic; 231 | TestTargetID = 1BF8158B1DDE15EC00D7DDAB; 232 | }; 233 | 1BF8158B1DDE15EC00D7DDAB = { 234 | CreatedOnToolsVersion = 8.2; 235 | ProvisioningStyle = Automatic; 236 | }; 237 | }; 238 | }; 239 | buildConfigurationList = 1BF815871DDE15EC00D7DDAB /* Build configuration list for PBXProject "VIPER" */; 240 | compatibilityVersion = "Xcode 3.2"; 241 | developmentRegion = English; 242 | hasScannedForEncodings = 0; 243 | knownRegions = ( 244 | en, 245 | Base, 246 | ); 247 | mainGroup = 1BF815831DDE15EC00D7DDAB; 248 | productRefGroup = 1BF8158D1DDE15EC00D7DDAB /* Products */; 249 | projectDirPath = ""; 250 | projectRoot = ""; 251 | targets = ( 252 | 1BF8158B1DDE15EC00D7DDAB /* VIPER */, 253 | 1B60501C1DE1FF3900B74DC3 /* VIPERTests */, 254 | ); 255 | }; 256 | /* End PBXProject section */ 257 | 258 | /* Begin PBXResourcesBuildPhase section */ 259 | 1B60501B1DE1FF3900B74DC3 /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | 1BF8158A1DDE15EC00D7DDAB /* Resources */ = { 267 | isa = PBXResourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | 1BF8159A1DDE15EC00D7DDAB /* LaunchScreen.storyboard in Resources */, 271 | 1BF815971DDE15EC00D7DDAB /* Assets.xcassets in Resources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | /* End PBXResourcesBuildPhase section */ 276 | 277 | /* Begin PBXSourcesBuildPhase section */ 278 | 1B6050191DE1FF3900B74DC3 /* Sources */ = { 279 | isa = PBXSourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | 1B6050371DE201DE00B74DC3 /* MainModule.swift in Sources */, 283 | 1B6050361DE201DE00B74DC3 /* MainPresenter.swift in Sources */, 284 | 1B60503B1DE201DE00B74DC3 /* DetailsViewController.swift in Sources */, 285 | 1B60503A1DE201DE00B74DC3 /* TextLoader.swift in Sources */, 286 | 1B6050321DE201DE00B74DC3 /* Context.swift in Sources */, 287 | 1B6050391DE201DE00B74DC3 /* TextLoaderProtocol.swift in Sources */, 288 | 1B6050341DE201DE00B74DC3 /* MainViewControllerProtocol.swift in Sources */, 289 | 1B60503C1DE201DE00B74DC3 /* Wireframe.swift in Sources */, 290 | 1B6050381DE201DE00B74DC3 /* Signal.swift in Sources */, 291 | 1B6050331DE201DE00B74DC3 /* Routing.swift in Sources */, 292 | 1B6050351DE201DE00B74DC3 /* MainViewController.swift in Sources */, 293 | 1B6050401DE206CD00B74DC3 /* VIPERTests.swift in Sources */, 294 | 1B60503E1DE201F200B74DC3 /* TestContext.swift in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | 1BF815881DDE15EC00D7DDAB /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | 1BF815B71DDE1F7D00D7DDAB /* Wireframe.swift in Sources */, 303 | 1B4581141DE1E47B003F96A2 /* Routing.swift in Sources */, 304 | 1BF815B91DDE217F00D7DDAB /* DetailsViewController.swift in Sources */, 305 | 1B4581121DE1DBDE003F96A2 /* Context.swift in Sources */, 306 | 1BF815901DDE15EC00D7DDAB /* AppDelegate.swift in Sources */, 307 | 1B45810E1DE1D6F1003F96A2 /* MainModule.swift in Sources */, 308 | 1BF815B51DDE185C00D7DDAB /* MainPresenter.swift in Sources */, 309 | 1B158F6E1DDF21150069E60E /* Signal.swift in Sources */, 310 | 1BD88B581DDEF1780059E401 /* TextLoaderProtocol.swift in Sources */, 311 | 1BF815B11DDE176C00D7DDAB /* MainViewControllerProtocol.swift in Sources */, 312 | 1BF815AE1DDE175700D7DDAB /* MainViewController.swift in Sources */, 313 | 1BD88B591DDEF1780059E401 /* TextLoader.swift in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | /* End PBXSourcesBuildPhase section */ 318 | 319 | /* Begin PBXTargetDependency section */ 320 | 1B6050231DE1FF3900B74DC3 /* PBXTargetDependency */ = { 321 | isa = PBXTargetDependency; 322 | target = 1BF8158B1DDE15EC00D7DDAB /* VIPER */; 323 | targetProxy = 1B6050221DE1FF3900B74DC3 /* PBXContainerItemProxy */; 324 | }; 325 | /* End PBXTargetDependency section */ 326 | 327 | /* Begin PBXVariantGroup section */ 328 | 1BF815981DDE15EC00D7DDAB /* LaunchScreen.storyboard */ = { 329 | isa = PBXVariantGroup; 330 | children = ( 331 | 1BF815991DDE15EC00D7DDAB /* Base */, 332 | ); 333 | name = LaunchScreen.storyboard; 334 | sourceTree = ""; 335 | }; 336 | /* End PBXVariantGroup section */ 337 | 338 | /* Begin XCBuildConfiguration section */ 339 | 1B6050241DE1FF3900B74DC3 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | BUNDLE_LOADER = "$(TEST_HOST)"; 343 | INFOPLIST_FILE = VIPERTests/Info.plist; 344 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 345 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.VIPERTests; 346 | PRODUCT_NAME = "$(TARGET_NAME)"; 347 | SWIFT_VERSION = 3.0; 348 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/VIPER.app/VIPER"; 349 | }; 350 | name = Debug; 351 | }; 352 | 1B6050251DE1FF3900B74DC3 /* Release */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | BUNDLE_LOADER = "$(TEST_HOST)"; 356 | INFOPLIST_FILE = VIPERTests/Info.plist; 357 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 358 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.VIPERTests; 359 | PRODUCT_NAME = "$(TARGET_NAME)"; 360 | SWIFT_VERSION = 3.0; 361 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/VIPER.app/VIPER"; 362 | }; 363 | name = Release; 364 | }; 365 | 1BF8159C1DDE15EC00D7DDAB /* Debug */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ALWAYS_SEARCH_USER_PATHS = NO; 369 | CLANG_ANALYZER_NONNULL = YES; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_WARN_BOOL_CONVERSION = YES; 375 | CLANG_WARN_CONSTANT_CONVERSION = YES; 376 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 377 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 378 | CLANG_WARN_EMPTY_BODY = YES; 379 | CLANG_WARN_ENUM_CONVERSION = YES; 380 | CLANG_WARN_INFINITE_RECURSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 384 | CLANG_WARN_UNREACHABLE_CODE = YES; 385 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 386 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 387 | COPY_PHASE_STRIP = NO; 388 | DEBUG_INFORMATION_FORMAT = dwarf; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | ENABLE_TESTABILITY = YES; 391 | GCC_C_LANGUAGE_STANDARD = gnu99; 392 | GCC_DYNAMIC_NO_PIC = NO; 393 | GCC_NO_COMMON_BLOCKS = YES; 394 | GCC_OPTIMIZATION_LEVEL = 0; 395 | GCC_PREPROCESSOR_DEFINITIONS = ( 396 | "DEBUG=1", 397 | "$(inherited)", 398 | ); 399 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 400 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 401 | GCC_WARN_UNDECLARED_SELECTOR = YES; 402 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 403 | GCC_WARN_UNUSED_FUNCTION = YES; 404 | GCC_WARN_UNUSED_VARIABLE = YES; 405 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 406 | MTL_ENABLE_DEBUG_INFO = YES; 407 | ONLY_ACTIVE_ARCH = YES; 408 | SDKROOT = iphoneos; 409 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 410 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 411 | }; 412 | name = Debug; 413 | }; 414 | 1BF8159D1DDE15EC00D7DDAB /* Release */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | ALWAYS_SEARCH_USER_PATHS = NO; 418 | CLANG_ANALYZER_NONNULL = YES; 419 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 420 | CLANG_CXX_LIBRARY = "libc++"; 421 | CLANG_ENABLE_MODULES = YES; 422 | CLANG_ENABLE_OBJC_ARC = YES; 423 | CLANG_WARN_BOOL_CONVERSION = YES; 424 | CLANG_WARN_CONSTANT_CONVERSION = YES; 425 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 426 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INFINITE_RECURSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 432 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 433 | CLANG_WARN_UNREACHABLE_CODE = YES; 434 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 435 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 436 | COPY_PHASE_STRIP = NO; 437 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 438 | ENABLE_NS_ASSERTIONS = NO; 439 | ENABLE_STRICT_OBJC_MSGSEND = YES; 440 | GCC_C_LANGUAGE_STANDARD = gnu99; 441 | GCC_NO_COMMON_BLOCKS = YES; 442 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 443 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 444 | GCC_WARN_UNDECLARED_SELECTOR = YES; 445 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 446 | GCC_WARN_UNUSED_FUNCTION = YES; 447 | GCC_WARN_UNUSED_VARIABLE = YES; 448 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 449 | MTL_ENABLE_DEBUG_INFO = NO; 450 | SDKROOT = iphoneos; 451 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 452 | VALIDATE_PRODUCT = YES; 453 | }; 454 | name = Release; 455 | }; 456 | 1BF8159F1DDE15EC00D7DDAB /* Debug */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 460 | INFOPLIST_FILE = VIPER/Info.plist; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 462 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.VIPER; 463 | PRODUCT_NAME = "$(TARGET_NAME)"; 464 | SWIFT_VERSION = 3.0; 465 | }; 466 | name = Debug; 467 | }; 468 | 1BF815A01DDE15EC00D7DDAB /* Release */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 472 | INFOPLIST_FILE = VIPER/Info.plist; 473 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 474 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.VIPER; 475 | PRODUCT_NAME = "$(TARGET_NAME)"; 476 | SWIFT_VERSION = 3.0; 477 | }; 478 | name = Release; 479 | }; 480 | /* End XCBuildConfiguration section */ 481 | 482 | /* Begin XCConfigurationList section */ 483 | 1B6050261DE1FF3900B74DC3 /* Build configuration list for PBXNativeTarget "VIPERTests" */ = { 484 | isa = XCConfigurationList; 485 | buildConfigurations = ( 486 | 1B6050241DE1FF3900B74DC3 /* Debug */, 487 | 1B6050251DE1FF3900B74DC3 /* Release */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | 1BF815871DDE15EC00D7DDAB /* Build configuration list for PBXProject "VIPER" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | 1BF8159C1DDE15EC00D7DDAB /* Debug */, 496 | 1BF8159D1DDE15EC00D7DDAB /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | 1BF8159E1DDE15EC00D7DDAB /* Build configuration list for PBXNativeTarget "VIPER" */ = { 502 | isa = XCConfigurationList; 503 | buildConfigurations = ( 504 | 1BF8159F1DDE15EC00D7DDAB /* Debug */, 505 | 1BF815A01DDE15EC00D7DDAB /* Release */, 506 | ); 507 | defaultConfigurationIsVisible = 0; 508 | defaultConfigurationName = Release; 509 | }; 510 | /* End XCConfigurationList section */ 511 | }; 512 | rootObject = 1BF815841DDE15EC00D7DDAB /* Project object */; 513 | } 514 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var wireframe: Wireframe? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | wireframe = Wireframe(context: ProductionContext()) 17 | 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/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 | 27 | 28 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/Context.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | typealias AppContext = TextLoaderContainer & MainModuleContainer & NavigationControllerContainer & WindowContainer 9 | 10 | 11 | class ProductionContext: AppContext { 12 | 13 | //internal singleton 14 | private static let textLoader = TextLoader() 15 | func makeTextLoader() -> TextLoaderProtocol { 16 | return ProductionContext.textLoader 17 | } 18 | 19 | func makeMainModule() -> (MainPresenter, MainViewProtocol) { 20 | let view = MainViewController() 21 | let presenter = MainPresenter(textLoader: makeTextLoader(), view: view) 22 | view.presenter = presenter 23 | return (presenter, view) 24 | } 25 | 26 | func makeNavigationView() -> NavigationView { 27 | return UINavigationController() 28 | } 29 | 30 | func makeWindow() -> Window { 31 | return UIWindow(frame: UIScreen.main.bounds) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController { 9 | 10 | 11 | private lazy var label = UILabel() 12 | 13 | private let text: String? 14 | 15 | init(text: String?) { 16 | self.text = text 17 | super.init(nibName: nil, bundle: nil) 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | title = "Details" 28 | 29 | view.backgroundColor = .white 30 | 31 | label.numberOfLines = 0 32 | label.text = text?.uppercased() 33 | view.addSubview(label) 34 | } 35 | 36 | override func viewDidLayoutSubviews() { 37 | super.viewDidLayoutSubviews() 38 | 39 | 40 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 41 | 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/MainModule.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | protocol MainModuleContainer { 9 | func makeMainModule() -> (MainPresenter, MainViewProtocol) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/MainPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class MainPresenter { 9 | 10 | var showDetails = Signal() 11 | 12 | let textLoader: TextLoaderProtocol 13 | unowned let view: MainViewProtocol 14 | 15 | init(textLoader: TextLoaderProtocol, view: MainViewProtocol) { 16 | self.textLoader = textLoader 17 | self.view = view 18 | 19 | view.detailsClick.subscribe {[unowned self] in 20 | self.showDetails.update() 21 | } 22 | 23 | view.loadClick.subscribe {[unowned self] in 24 | self.view.loading.update(true) 25 | self.view.text.update(nil) 26 | self.textLoader.loadText { 27 | self.view.loading.update(false) 28 | self.view.text.update($0) 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainViewController: UIViewController, MainViewProtocol { 9 | 10 | var presenter: Any? 11 | 12 | private lazy var button = UIButton(type: .system) 13 | private lazy var label = UILabel() 14 | private lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 15 | 16 | 17 | let loading = Signal() 18 | let text = Signal() 19 | let loadClick = Signal() 20 | let detailsClick = Signal() 21 | 22 | init() { 23 | 24 | super.init(nibName: nil, bundle: nil) 25 | 26 | //FRP: text.bind(label.xx_text) 27 | //FRP: text.isNil.not.bind(navigationItem.rightBarButtonItem.xx_isEnabled) 28 | text.subscribe {[weak self] in 29 | self?.label.text = $0 30 | self?.navigationItem.rightBarButtonItem?.isEnabled = ($0 != nil) 31 | } 32 | 33 | //FRP: loading.bind(activityIndicator.xx_animating) 34 | loading.subscribe {[weak self] in 35 | if $0 { 36 | self?.activityIndicator.startAnimating() 37 | } else { 38 | self?.activityIndicator.stopAnimating() 39 | } 40 | } 41 | } 42 | 43 | required init?(coder aDecoder: NSCoder) { 44 | fatalError() 45 | } 46 | 47 | override func viewDidLoad() { 48 | super.viewDidLoad() 49 | 50 | title = "MVP+Routing+Bindings" 51 | 52 | view.backgroundColor = .white 53 | 54 | view.addSubview(activityIndicator) 55 | 56 | button.setTitle("Load", for: .normal) 57 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 58 | view.addSubview(button) 59 | 60 | label.numberOfLines = 0 61 | view.addSubview(label) 62 | 63 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(detailsClicked)) 64 | navigationItem.rightBarButtonItem?.isEnabled = false 65 | } 66 | 67 | override func viewDidLayoutSubviews() { 68 | super.viewDidLayoutSubviews() 69 | 70 | activityIndicator.frame = view.bounds 71 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 72 | button.frame = CGRect(x: 20, y: view.bounds.height - 60, width: view.bounds.width - 40, height: 40) 73 | } 74 | 75 | @objc private func detailsClicked() { 76 | detailsClick.update() 77 | } 78 | 79 | @objc private func buttonClicked() { 80 | loadClick.update() 81 | } 82 | } 83 | 84 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/MainViewControllerProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol MainViewProtocol: View { 9 | var loading: Signal {get} 10 | var text: Signal {get} 11 | var loadClick: Signal {get} 12 | var detailsClick: Signal {get} 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/Routing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | protocol View: class { 9 | var viewController: UIViewController {get} 10 | } 11 | 12 | 13 | 14 | protocol NavigationView: View { 15 | func pushView(view: View, animated: Bool) 16 | func popView(view: View, animated: Bool) -> View 17 | 18 | var views: [View] {get set} 19 | } 20 | 21 | protocol NavigationControllerContainer { 22 | func makeNavigationView() -> NavigationView 23 | } 24 | 25 | extension NavigationView where Self: UINavigationController { 26 | 27 | func pushView(view: View, animated: Bool) { 28 | pushViewController(view.viewController, animated: animated) 29 | } 30 | 31 | func popView(view: View, animated: Bool) -> View { 32 | return popViewController(animated: animated) as! View 33 | } 34 | 35 | var views: [View] { 36 | set { 37 | viewControllers = newValue.map { $0.viewController } 38 | } 39 | get { 40 | return viewControllers 41 | } 42 | } 43 | } 44 | 45 | extension UINavigationController: NavigationView { 46 | } 47 | 48 | protocol Window { 49 | var rootView: View? {get set} 50 | func install() 51 | } 52 | 53 | protocol WindowContainer { 54 | func makeWindow() -> Window 55 | } 56 | 57 | extension Window where Self: UIWindow { 58 | 59 | var rootView: View? { 60 | set { 61 | rootViewController = newValue?.viewController 62 | } 63 | get { 64 | return rootViewController 65 | } 66 | } 67 | 68 | func install() { 69 | makeKeyAndVisible() 70 | } 71 | } 72 | 73 | extension UIWindow: Window { 74 | 75 | } 76 | 77 | extension UIViewController: View { 78 | var viewController: UIViewController { 79 | return self 80 | } 81 | } 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class Signal { 9 | 10 | private var _value: T? 11 | 12 | private var _callbacks: [(T)->Void] = [] 13 | 14 | var lastValue: T? { 15 | return _value 16 | } 17 | 18 | func subscribe(_ callback: @escaping (T)->Void) { 19 | 20 | _callbacks.append(callback) 21 | 22 | if let value = _value { 23 | callback(value) 24 | } 25 | } 26 | 27 | func update(_ newValue: T) { 28 | _value = newValue 29 | 30 | _callbacks.forEach { 31 | $0(newValue) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/TextLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class TextLoader: TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) { 10 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 11 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/TextLoaderProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) 10 | } 11 | 12 | protocol TextLoaderContainer { 13 | func makeTextLoader() -> TextLoaderProtocol 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPER/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class Wireframe { 9 | 10 | let window: Window 11 | let navigationView: NavigationView 12 | 13 | init(context: AppContext) { 14 | window = context.makeWindow() 15 | 16 | let (presenter, view) = context.makeMainModule() 17 | 18 | navigationView = context.makeNavigationView() 19 | navigationView.views = [view] 20 | 21 | window.rootView = navigationView 22 | 23 | window.install() 24 | 25 | presenter.showDetails.subscribe {[unowned self, unowned presenter] in 26 | let vc = DetailsViewController(text: presenter.view.text.lastValue ?? nil) 27 | self.navigationView.pushView(view: vc, animated: true) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPERTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPERTests/TestContext.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class TestContext: AppContext { 9 | 10 | struct Config { 11 | var text = "Hello" 12 | } 13 | let config: Config 14 | init(config: Config) { 15 | self.config = config 16 | } 17 | 18 | func makeTextLoader() -> TextLoaderProtocol { 19 | return TestTextLoader(text: config.text) 20 | } 21 | 22 | func makeMainModule() -> (MainPresenter, MainViewProtocol) { 23 | let view = TestMainView() 24 | let presenter = MainPresenter(textLoader: makeTextLoader(), view: view) 25 | view.presenter = presenter 26 | return (presenter, view) 27 | } 28 | 29 | func makeNavigationView() -> NavigationView { 30 | return TestNavigationView() 31 | } 32 | 33 | func makeWindow() -> Window { 34 | return TestWindow() 35 | } 36 | } 37 | 38 | class TestTextLoader: TextLoaderProtocol { 39 | let text: String 40 | init(text: String) { 41 | self.text = text 42 | } 43 | func loadText(completion: @escaping (String) -> Void) { 44 | completion(text) 45 | } 46 | } 47 | 48 | class TestView { 49 | var presenter: Any? 50 | } 51 | 52 | class TestMainView: TestView, MainViewProtocol { 53 | var loading = Signal() 54 | var text = Signal() 55 | var loadClick = Signal() 56 | var detailsClick = Signal() 57 | 58 | var viewController: UIViewController { 59 | fatalError() 60 | } 61 | } 62 | 63 | class TestNavigationView: NavigationView { 64 | func pushView(view: View, animated: Bool) { 65 | views.append(view) 66 | } 67 | 68 | func popView(view: View, animated: Bool) -> View { 69 | return views.removeLast() 70 | } 71 | 72 | var views: [View] = [] 73 | 74 | var viewController: UIViewController { 75 | fatalError() 76 | } 77 | } 78 | 79 | class TestWindow: Window { 80 | var rootView: View? 81 | func install() { 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /5. MVP+Routing+Bindings/VIPERTests/VIPERTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VIPERTests.swift 3 | // VIPERTests 4 | // 5 | // Created by Pavel Sharanda on 20.11.16. 6 | // Copyright © 2016 psharanda. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class VIPERTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | let res = "Lorem Ipsum" 25 | var config = TestContext.Config() 26 | config.text = res 27 | let context = TestContext(config: config) 28 | let (_, view) = context.makeMainModule() 29 | 30 | view.loadClick.update() 31 | 32 | XCTAssertEqual(view.text.lastValue!, res) 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1B75F9FF1DDF232C0075E6EB /* Wireframe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B75F9FE1DDF232C0075E6EB /* Wireframe.swift */; }; 11 | 1BF8155D1DDE0C0800D7DDAB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8155C1DDE0C0800D7DDAB /* AppDelegate.swift */; }; 12 | 1BF815641DDE0C0800D7DDAB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815631DDE0C0800D7DDAB /* Assets.xcassets */; }; 13 | 1BF815671DDE0C0800D7DDAB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1BF815651DDE0C0800D7DDAB /* LaunchScreen.storyboard */; }; 14 | 1BF815731DDE0CB600D7DDAB /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815711DDE0CB600D7DDAB /* DetailsViewController.swift */; }; 15 | 1BF815741DDE0CB600D7DDAB /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815721DDE0CB600D7DDAB /* MainViewController.swift */; }; 16 | 1BF815781DDE0CDB00D7DDAB /* MainViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815771DDE0CDB00D7DDAB /* MainViewModel.swift */; }; 17 | 1BF8157A1DDE0CF200D7DDAB /* MainViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815791DDE0CF200D7DDAB /* MainViewModelProtocol.swift */; }; 18 | 1BF8157E1DDE0D2500D7DDAB /* Signal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8157D1DDE0D2500D7DDAB /* Signal.swift */; }; 19 | 1BF815811DDE0EA800D7DDAB /* TextLoaderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF8157F1DDE0EA800D7DDAB /* TextLoaderProtocol.swift */; }; 20 | 1BF815821DDE0EA800D7DDAB /* TextLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BF815801DDE0EA800D7DDAB /* TextLoader.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 1B75F9FE1DDF232C0075E6EB /* Wireframe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wireframe.swift; sourceTree = ""; }; 25 | 1BF815591DDE0C0800D7DDAB /* MVVM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MVVM.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | 1BF8155C1DDE0C0800D7DDAB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 27 | 1BF815631DDE0C0800D7DDAB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 1BF815661DDE0C0800D7DDAB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 1BF815681DDE0C0800D7DDAB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 1BF815711DDE0CB600D7DDAB /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = ""; }; 31 | 1BF815721DDE0CB600D7DDAB /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = ""; }; 32 | 1BF815771DDE0CDB00D7DDAB /* MainViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewModel.swift; sourceTree = ""; }; 33 | 1BF815791DDE0CF200D7DDAB /* MainViewModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewModelProtocol.swift; sourceTree = ""; }; 34 | 1BF8157D1DDE0D2500D7DDAB /* Signal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Signal.swift; sourceTree = ""; }; 35 | 1BF8157F1DDE0EA800D7DDAB /* TextLoaderProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoaderProtocol.swift; sourceTree = ""; }; 36 | 1BF815801DDE0EA800D7DDAB /* TextLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextLoader.swift; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | 1BF815561DDE0C0800D7DDAB /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | 1B75F9FD1DDF231A0075E6EB /* Routing */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 1B75F9FE1DDF232C0075E6EB /* Wireframe.swift */, 54 | ); 55 | name = Routing; 56 | sourceTree = ""; 57 | }; 58 | 1BF815501DDE0C0800D7DDAB = { 59 | isa = PBXGroup; 60 | children = ( 61 | 1BF8155B1DDE0C0800D7DDAB /* MVVM */, 62 | 1BF8155A1DDE0C0800D7DDAB /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 1BF8155A1DDE0C0800D7DDAB /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 1BF815591DDE0C0800D7DDAB /* MVVM.app */, 70 | ); 71 | name = Products; 72 | sourceTree = ""; 73 | }; 74 | 1BF8155B1DDE0C0800D7DDAB /* MVVM */ = { 75 | isa = PBXGroup; 76 | children = ( 77 | 1BF8157D1DDE0D2500D7DDAB /* Signal.swift */, 78 | 1BF8156E1DDE0C3D00D7DDAB /* Model */, 79 | 1BF8156F1DDE0C4200D7DDAB /* View */, 80 | 1BF815701DDE0C4900D7DDAB /* ViewModel */, 81 | 1B75F9FD1DDF231A0075E6EB /* Routing */, 82 | 1BF8155C1DDE0C0800D7DDAB /* AppDelegate.swift */, 83 | 1BF815631DDE0C0800D7DDAB /* Assets.xcassets */, 84 | 1BF815651DDE0C0800D7DDAB /* LaunchScreen.storyboard */, 85 | 1BF815681DDE0C0800D7DDAB /* Info.plist */, 86 | ); 87 | path = MVVM; 88 | sourceTree = ""; 89 | }; 90 | 1BF8156E1DDE0C3D00D7DDAB /* Model */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 1BF8157F1DDE0EA800D7DDAB /* TextLoaderProtocol.swift */, 94 | 1BF815801DDE0EA800D7DDAB /* TextLoader.swift */, 95 | ); 96 | name = Model; 97 | sourceTree = ""; 98 | }; 99 | 1BF8156F1DDE0C4200D7DDAB /* View */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 1BF815721DDE0CB600D7DDAB /* MainViewController.swift */, 103 | 1BF815711DDE0CB600D7DDAB /* DetailsViewController.swift */, 104 | ); 105 | name = View; 106 | sourceTree = ""; 107 | }; 108 | 1BF815701DDE0C4900D7DDAB /* ViewModel */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 1BF815791DDE0CF200D7DDAB /* MainViewModelProtocol.swift */, 112 | 1BF815771DDE0CDB00D7DDAB /* MainViewModel.swift */, 113 | ); 114 | name = ViewModel; 115 | sourceTree = ""; 116 | }; 117 | /* End PBXGroup section */ 118 | 119 | /* Begin PBXNativeTarget section */ 120 | 1BF815581DDE0C0800D7DDAB /* MVVM */ = { 121 | isa = PBXNativeTarget; 122 | buildConfigurationList = 1BF8156B1DDE0C0800D7DDAB /* Build configuration list for PBXNativeTarget "MVVM" */; 123 | buildPhases = ( 124 | 1BF815551DDE0C0800D7DDAB /* Sources */, 125 | 1BF815561DDE0C0800D7DDAB /* Frameworks */, 126 | 1BF815571DDE0C0800D7DDAB /* Resources */, 127 | ); 128 | buildRules = ( 129 | ); 130 | dependencies = ( 131 | ); 132 | name = MVVM; 133 | productName = MVVM; 134 | productReference = 1BF815591DDE0C0800D7DDAB /* MVVM.app */; 135 | productType = "com.apple.product-type.application"; 136 | }; 137 | /* End PBXNativeTarget section */ 138 | 139 | /* Begin PBXProject section */ 140 | 1BF815511DDE0C0800D7DDAB /* Project object */ = { 141 | isa = PBXProject; 142 | attributes = { 143 | LastSwiftUpdateCheck = 0820; 144 | LastUpgradeCheck = 0820; 145 | ORGANIZATIONNAME = psharanda; 146 | TargetAttributes = { 147 | 1BF815581DDE0C0800D7DDAB = { 148 | CreatedOnToolsVersion = 8.2; 149 | ProvisioningStyle = Automatic; 150 | }; 151 | }; 152 | }; 153 | buildConfigurationList = 1BF815541DDE0C0800D7DDAB /* Build configuration list for PBXProject "MVVM" */; 154 | compatibilityVersion = "Xcode 3.2"; 155 | developmentRegion = English; 156 | hasScannedForEncodings = 0; 157 | knownRegions = ( 158 | en, 159 | Base, 160 | ); 161 | mainGroup = 1BF815501DDE0C0800D7DDAB; 162 | productRefGroup = 1BF8155A1DDE0C0800D7DDAB /* Products */; 163 | projectDirPath = ""; 164 | projectRoot = ""; 165 | targets = ( 166 | 1BF815581DDE0C0800D7DDAB /* MVVM */, 167 | ); 168 | }; 169 | /* End PBXProject section */ 170 | 171 | /* Begin PBXResourcesBuildPhase section */ 172 | 1BF815571DDE0C0800D7DDAB /* Resources */ = { 173 | isa = PBXResourcesBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | 1BF815671DDE0C0800D7DDAB /* LaunchScreen.storyboard in Resources */, 177 | 1BF815641DDE0C0800D7DDAB /* Assets.xcassets in Resources */, 178 | ); 179 | runOnlyForDeploymentPostprocessing = 0; 180 | }; 181 | /* End PBXResourcesBuildPhase section */ 182 | 183 | /* Begin PBXSourcesBuildPhase section */ 184 | 1BF815551DDE0C0800D7DDAB /* Sources */ = { 185 | isa = PBXSourcesBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | 1BF815781DDE0CDB00D7DDAB /* MainViewModel.swift in Sources */, 189 | 1BF815741DDE0CB600D7DDAB /* MainViewController.swift in Sources */, 190 | 1BF815821DDE0EA800D7DDAB /* TextLoader.swift in Sources */, 191 | 1BF8155D1DDE0C0800D7DDAB /* AppDelegate.swift in Sources */, 192 | 1BF815811DDE0EA800D7DDAB /* TextLoaderProtocol.swift in Sources */, 193 | 1B75F9FF1DDF232C0075E6EB /* Wireframe.swift in Sources */, 194 | 1BF8157A1DDE0CF200D7DDAB /* MainViewModelProtocol.swift in Sources */, 195 | 1BF8157E1DDE0D2500D7DDAB /* Signal.swift in Sources */, 196 | 1BF815731DDE0CB600D7DDAB /* DetailsViewController.swift in Sources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | /* End PBXSourcesBuildPhase section */ 201 | 202 | /* Begin PBXVariantGroup section */ 203 | 1BF815651DDE0C0800D7DDAB /* LaunchScreen.storyboard */ = { 204 | isa = PBXVariantGroup; 205 | children = ( 206 | 1BF815661DDE0C0800D7DDAB /* Base */, 207 | ); 208 | name = LaunchScreen.storyboard; 209 | sourceTree = ""; 210 | }; 211 | /* End PBXVariantGroup section */ 212 | 213 | /* Begin XCBuildConfiguration section */ 214 | 1BF815691DDE0C0800D7DDAB /* Debug */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 220 | CLANG_CXX_LIBRARY = "libc++"; 221 | CLANG_ENABLE_MODULES = YES; 222 | CLANG_ENABLE_OBJC_ARC = YES; 223 | CLANG_WARN_BOOL_CONVERSION = YES; 224 | CLANG_WARN_CONSTANT_CONVERSION = YES; 225 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 226 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 227 | CLANG_WARN_EMPTY_BODY = YES; 228 | CLANG_WARN_ENUM_CONVERSION = YES; 229 | CLANG_WARN_INFINITE_RECURSION = YES; 230 | CLANG_WARN_INT_CONVERSION = YES; 231 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 232 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 233 | CLANG_WARN_UNREACHABLE_CODE = YES; 234 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 235 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 236 | COPY_PHASE_STRIP = NO; 237 | DEBUG_INFORMATION_FORMAT = dwarf; 238 | ENABLE_STRICT_OBJC_MSGSEND = YES; 239 | ENABLE_TESTABILITY = YES; 240 | GCC_C_LANGUAGE_STANDARD = gnu99; 241 | GCC_DYNAMIC_NO_PIC = NO; 242 | GCC_NO_COMMON_BLOCKS = YES; 243 | GCC_OPTIMIZATION_LEVEL = 0; 244 | GCC_PREPROCESSOR_DEFINITIONS = ( 245 | "DEBUG=1", 246 | "$(inherited)", 247 | ); 248 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 249 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 250 | GCC_WARN_UNDECLARED_SELECTOR = YES; 251 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 252 | GCC_WARN_UNUSED_FUNCTION = YES; 253 | GCC_WARN_UNUSED_VARIABLE = YES; 254 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 255 | MTL_ENABLE_DEBUG_INFO = YES; 256 | ONLY_ACTIVE_ARCH = YES; 257 | SDKROOT = iphoneos; 258 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 259 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 260 | }; 261 | name = Debug; 262 | }; 263 | 1BF8156A1DDE0C0800D7DDAB /* Release */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ALWAYS_SEARCH_USER_PATHS = NO; 267 | CLANG_ANALYZER_NONNULL = YES; 268 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 269 | CLANG_CXX_LIBRARY = "libc++"; 270 | CLANG_ENABLE_MODULES = YES; 271 | CLANG_ENABLE_OBJC_ARC = YES; 272 | CLANG_WARN_BOOL_CONVERSION = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 275 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 276 | CLANG_WARN_EMPTY_BODY = YES; 277 | CLANG_WARN_ENUM_CONVERSION = YES; 278 | CLANG_WARN_INFINITE_RECURSION = YES; 279 | CLANG_WARN_INT_CONVERSION = YES; 280 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 281 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 282 | CLANG_WARN_UNREACHABLE_CODE = YES; 283 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 284 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 285 | COPY_PHASE_STRIP = NO; 286 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 287 | ENABLE_NS_ASSERTIONS = NO; 288 | ENABLE_STRICT_OBJC_MSGSEND = YES; 289 | GCC_C_LANGUAGE_STANDARD = gnu99; 290 | GCC_NO_COMMON_BLOCKS = YES; 291 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 292 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 293 | GCC_WARN_UNDECLARED_SELECTOR = YES; 294 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 295 | GCC_WARN_UNUSED_FUNCTION = YES; 296 | GCC_WARN_UNUSED_VARIABLE = YES; 297 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 298 | MTL_ENABLE_DEBUG_INFO = NO; 299 | SDKROOT = iphoneos; 300 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 301 | VALIDATE_PRODUCT = YES; 302 | }; 303 | name = Release; 304 | }; 305 | 1BF8156C1DDE0C0800D7DDAB /* Debug */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 309 | INFOPLIST_FILE = MVVM/Info.plist; 310 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 311 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.MVVM; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | SWIFT_VERSION = 3.0; 314 | }; 315 | name = Debug; 316 | }; 317 | 1BF8156D1DDE0C0800D7DDAB /* Release */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 321 | INFOPLIST_FILE = MVVM/Info.plist; 322 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 323 | PRODUCT_BUNDLE_IDENTIFIER = org.psharanda.MVVM; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SWIFT_VERSION = 3.0; 326 | }; 327 | name = Release; 328 | }; 329 | /* End XCBuildConfiguration section */ 330 | 331 | /* Begin XCConfigurationList section */ 332 | 1BF815541DDE0C0800D7DDAB /* Build configuration list for PBXProject "MVVM" */ = { 333 | isa = XCConfigurationList; 334 | buildConfigurations = ( 335 | 1BF815691DDE0C0800D7DDAB /* Debug */, 336 | 1BF8156A1DDE0C0800D7DDAB /* Release */, 337 | ); 338 | defaultConfigurationIsVisible = 0; 339 | defaultConfigurationName = Release; 340 | }; 341 | 1BF8156B1DDE0C0800D7DDAB /* Build configuration list for PBXNativeTarget "MVVM" */ = { 342 | isa = XCConfigurationList; 343 | buildConfigurations = ( 344 | 1BF8156C1DDE0C0800D7DDAB /* Debug */, 345 | 1BF8156D1DDE0C0800D7DDAB /* Release */, 346 | ); 347 | defaultConfigurationIsVisible = 0; 348 | defaultConfigurationName = Release; 349 | }; 350 | /* End XCConfigurationList section */ 351 | }; 352 | rootObject = 1BF815511DDE0C0800D7DDAB /* Project object */; 353 | } 354 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var wireframe: Wireframe? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | wireframe = Wireframe() 17 | 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/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 | 27 | 28 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController { 9 | 10 | private lazy var label = UILabel() 11 | 12 | private let text: String? 13 | 14 | init(text: String?) { 15 | self.text = text 16 | super.init(nibName: nil, bundle: nil) 17 | } 18 | 19 | required init?(coder aDecoder: NSCoder) { 20 | fatalError("init(coder:) has not been implemented") 21 | } 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | title = "Details" 27 | 28 | view.backgroundColor = .white 29 | 30 | label.numberOfLines = 0 31 | label.text = text?.uppercased() 32 | view.addSubview(label) 33 | } 34 | 35 | override func viewDidLayoutSubviews() { 36 | super.viewDidLayoutSubviews() 37 | 38 | 39 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 40 | 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainViewController: UIViewController { 9 | 10 | private lazy var button = UIButton(type: .system) 11 | private lazy var label = UILabel() 12 | private lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 13 | 14 | let viewModel: MainViewModelProtocol 15 | 16 | init(viewModel: MainViewModelProtocol) { 17 | self.viewModel = viewModel 18 | super.init(nibName: nil, bundle: nil) 19 | 20 | //FRP: self.viewModel.text.bind(label.xx_text) 21 | //FRP: self.viewModel.text.isNil.not.bind(navigationItem.rightBarButtonItem.xx_isEnabled) 22 | self.viewModel.text.subscribe {[weak self] in 23 | self?.label.text = $0 24 | self?.navigationItem.rightBarButtonItem?.isEnabled = ($0 != nil) 25 | } 26 | 27 | //FRP: self.viewModel.loading.bind(activityIndicator.xx_animating) 28 | self.viewModel.loading.subscribe {[weak self] in 29 | if $0 { 30 | self?.activityIndicator.startAnimating() 31 | } else { 32 | self?.activityIndicator.stopAnimating() 33 | } 34 | } 35 | 36 | 37 | } 38 | 39 | required init?(coder aDecoder: NSCoder) { 40 | fatalError() 41 | } 42 | 43 | override func viewDidLoad() { 44 | super.viewDidLoad() 45 | 46 | title = "MVVM" 47 | 48 | view.backgroundColor = .white 49 | 50 | view.addSubview(activityIndicator) 51 | 52 | button.setTitle("Load", for: .normal) 53 | 54 | //FRP: button.xx_click.bind(viewModel.loadClick) 55 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 56 | 57 | view.addSubview(button) 58 | 59 | label.numberOfLines = 0 60 | view.addSubview(label) 61 | 62 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(detailsClicked)) 63 | navigationItem.rightBarButtonItem?.isEnabled = false 64 | } 65 | 66 | override func viewDidLayoutSubviews() { 67 | super.viewDidLayoutSubviews() 68 | 69 | activityIndicator.frame = view.bounds 70 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 71 | button.frame = CGRect(x: 20, y: view.bounds.height - 60, width: view.bounds.width - 40, height: 40) 72 | } 73 | 74 | @objc private func detailsClicked() { 75 | viewModel.detailsClick.update() 76 | } 77 | 78 | @objc private func buttonClicked() { 79 | viewModel.loadClick.update() 80 | } 81 | } 82 | 83 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/MainViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class MainViewModel: MainViewModelProtocol { 9 | 10 | let loading = Signal() 11 | let text = Signal() 12 | let loadClick = Signal() 13 | let detailsClick = Signal() 14 | 15 | let textLoader: TextLoaderProtocol 16 | 17 | init(textLoader: TextLoaderProtocol) { 18 | 19 | self.textLoader = textLoader 20 | 21 | loadClick.subscribe {[unowned self] in 22 | self.loading.update(true) 23 | self.text.update(nil) 24 | self.textLoader.loadText { 25 | self.loading.update(false) 26 | self.text.update($0) 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/MainViewModelProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol MainViewModelProtocol { 9 | var loading: Signal {get} 10 | var text: Signal {get} 11 | var loadClick: Signal {get} 12 | var detailsClick: Signal {get} 13 | } 14 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class Signal { 9 | 10 | private var _value: T? 11 | 12 | private var _callbacks: [(T)->Void] = [] 13 | 14 | var lastValue: T? { 15 | return _value 16 | } 17 | 18 | func subscribe(_ callback: @escaping (T)->Void) { 19 | 20 | _callbacks.append(callback) 21 | 22 | if let value = _value { 23 | callback(value) 24 | } 25 | } 26 | 27 | func update(_ newValue: T) { 28 | _value = newValue 29 | 30 | _callbacks.forEach { 31 | $0(newValue) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/TextLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class TextLoader: TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) { 10 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 11 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/TextLoaderProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) 10 | } 11 | -------------------------------------------------------------------------------- /6. MVVM+Bindings/MVVM/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class Wireframe { 9 | 10 | let window: UIWindow 11 | let navigationController: UINavigationController 12 | init() { 13 | window = UIWindow(frame: UIScreen.main.bounds) 14 | 15 | let viewModel = MainViewModel(textLoader: TextLoader()) 16 | let vc = MainViewController(viewModel: viewModel) 17 | 18 | navigationController = UINavigationController(rootViewController: vc) 19 | window.rootViewController = navigationController 20 | window.makeKeyAndVisible() 21 | 22 | viewModel.detailsClick.subscribe {[unowned self, unowned viewModel] in 23 | let vc = DetailsViewController(text: viewModel.text.lastValue ?? nil) 24 | self.navigationController.pushViewController(vc, animated: true) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var wireframe: Wireframe? 12 | 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 15 | 16 | wireframe = Wireframe(context: ProductionContext()) 17 | 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/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 | 27 | 28 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/DetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class DetailsViewController: UIViewController, DetailsViewProtocol { 9 | 10 | 11 | private lazy var label = UILabel() 12 | 13 | private let text: String 14 | 15 | init(text: String) { 16 | self.text = text 17 | super.init(nibName: nil, bundle: nil) 18 | } 19 | 20 | required init?(coder aDecoder: NSCoder) { 21 | fatalError("init(coder:) has not been implemented") 22 | } 23 | 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | title = "Details" 28 | 29 | view.backgroundColor = .white 30 | 31 | label.numberOfLines = 0 32 | label.text = text.uppercased() 33 | view.addSubview(label) 34 | } 35 | 36 | override func viewDidLayoutSubviews() { 37 | super.viewDidLayoutSubviews() 38 | 39 | 40 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 41 | 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/DetailsViewProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DetailsViewControllerProtocol.swift 3 | // MVPBRF 4 | 5 | import Foundation 6 | 7 | protocol DetailsViewContainer { 8 | func makeDetailsView(text: String) -> DetailsViewProtocol 9 | } 10 | 11 | protocol DetailsViewProtocol: View { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/MainPresenter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class MainPresenter { 9 | 10 | var showDetails = Signal() 11 | 12 | let textLoader: TextLoaderProtocol 13 | unowned let view: MainViewProtocol 14 | 15 | init(textLoader: TextLoaderProtocol, view: MainViewProtocol) { 16 | self.textLoader = textLoader 17 | self.view = view 18 | 19 | view.detailsClick.subscribe {[unowned self] in 20 | self.showDetails.update() 21 | } 22 | 23 | view.loadClick.subscribe {[unowned self] in 24 | 25 | self.view.state = MainViewState(loading: true, text: nil) 26 | self.textLoader.loadText { 27 | self.view.state = MainViewState(loading: false, text: $0) 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/MainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class MainViewController: UIViewController, MainViewProtocol { 9 | 10 | 11 | private lazy var button = UIButton(type: .system) 12 | private lazy var label = UILabel() 13 | private lazy var activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: .gray) 14 | 15 | 16 | var state: MainViewState = MainViewState() { 17 | didSet { 18 | render(oldState: oldValue, newState: state) 19 | } 20 | } 21 | 22 | let loadClick = Signal() 23 | let detailsClick = Signal() 24 | 25 | //MARK: 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | title = "SilverMVC" 31 | 32 | view.backgroundColor = .white 33 | 34 | view.addSubview(activityIndicator) 35 | 36 | button.setTitle("Load", for: .normal) 37 | button.addTarget(self, action: #selector(buttonClicked), for: .touchUpInside) 38 | view.addSubview(button) 39 | 40 | label.numberOfLines = 0 41 | view.addSubview(label) 42 | 43 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Details", style: .plain, target: self, action: #selector(detailsClicked)) 44 | 45 | render(oldState: state, newState: state) 46 | } 47 | 48 | override func viewDidLayoutSubviews() { 49 | super.viewDidLayoutSubviews() 50 | 51 | activityIndicator.frame = view.bounds 52 | label.frame = UIEdgeInsetsInsetRect(view.bounds, UIEdgeInsets(top: 80, left: 20, bottom: 80, right: 20)) 53 | button.frame = CGRect(x: 20, y: view.bounds.height - 60, width: view.bounds.width - 40, height: 40) 54 | } 55 | 56 | //MARK: 57 | 58 | @objc private func detailsClicked() { 59 | detailsClick.update() 60 | } 61 | 62 | @objc private func buttonClicked() { 63 | loadClick.update() 64 | } 65 | 66 | //MARK: - 67 | 68 | func render(oldState: MainViewState, newState: MainViewState) { 69 | label.text = state.text 70 | if state.loading { 71 | activityIndicator.startAnimating() 72 | } else { 73 | activityIndicator.stopAnimating() 74 | } 75 | navigationItem.rightBarButtonItem?.isEnabled = ((label.text?.characters.count) ?? 0) > 0 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/MainViewProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol MainViewContainer { 9 | func makeMainView() -> MainViewProtocol 10 | } 11 | 12 | struct MainViewState { 13 | var loading: Bool = false 14 | var text: String? = nil 15 | } 16 | 17 | protocol MainViewProtocol: View { 18 | 19 | var loadClick: Signal {get} 20 | var detailsClick: Signal {get} 21 | 22 | var state: MainViewState {get set} 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/ProductionContext.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | 9 | class ProductionContext: AppContext { 10 | 11 | //example of internal singleton 12 | private static let textLoader = TextLoader() 13 | func makeTextLoader() -> TextLoaderProtocol { 14 | return ProductionContext.textLoader 15 | } 16 | 17 | func makeMainView() -> MainViewProtocol { 18 | return MainViewController() 19 | } 20 | 21 | func makeDetailsView(text: String) -> DetailsViewProtocol { 22 | return DetailsViewController(text: text) 23 | } 24 | 25 | func makeNavigationView() -> NavigationView { 26 | return UINavigationController() 27 | } 28 | 29 | func makeWindow() -> Window { 30 | return UIWindow(frame: UIScreen.main.bounds) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/Routing+UIKit.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 23.02.17. 3 | // Copyright © 2017 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | extension UINavigationController: NavigationView {} 9 | 10 | extension NavigationView where Self: UINavigationController { 11 | 12 | func pushView(view: View, animated: Bool) { 13 | pushViewController(view as! UIViewController, animated: animated) 14 | } 15 | 16 | func popView(view: View, animated: Bool) -> View? { 17 | return popViewController(animated: animated) 18 | } 19 | 20 | var views: [View] { 21 | set { 22 | viewControllers = newValue.map { $0 as! UIViewController } 23 | } 24 | get { 25 | return viewControllers 26 | } 27 | } 28 | } 29 | 30 | 31 | extension UIWindow: Window {} 32 | 33 | extension Window where Self: UIWindow { 34 | 35 | var rootView: View? { 36 | set { 37 | rootViewController = newValue as! UIViewController? 38 | } 39 | get { 40 | return rootViewController 41 | } 42 | } 43 | 44 | func install() { 45 | makeKeyAndVisible() 46 | } 47 | } 48 | 49 | private var presenterKey: Int = 0 50 | 51 | extension UIViewController: View { 52 | 53 | var presenter: AnyObject? { 54 | get { 55 | return objc_getAssociatedObject(self, &presenterKey) as AnyObject 56 | } 57 | 58 | set { 59 | objc_setAssociatedObject(self, &presenterKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/Routing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol View: class { 9 | var presenter: AnyObject? {get set} 10 | } 11 | 12 | protocol NavigationView: View { 13 | func pushView(view: View, animated: Bool) 14 | func popView(view: View, animated: Bool) -> View? 15 | 16 | var views: [View] {get set} 17 | } 18 | 19 | protocol Window: class { 20 | var rootView: View? {get set} 21 | func install() 22 | } 23 | 24 | protocol NavigationControllerContainer { 25 | func makeNavigationView() -> NavigationView 26 | } 27 | 28 | protocol WindowContainer { 29 | func makeWindow() -> Window 30 | } 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/Signal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | 9 | class Signal { 10 | 11 | private var value: T? 12 | 13 | private var callbacks: [(T)->Void] = [] 14 | 15 | var lastValue: T? { 16 | return value 17 | } 18 | 19 | func subscribe(_ callback: @escaping (T)->Void) { 20 | 21 | callbacks.append(callback) 22 | 23 | if let value = value { 24 | callback(value) 25 | } 26 | } 27 | 28 | func update(_ newValue: T) { 29 | value = newValue 30 | 31 | callbacks.forEach { 32 | $0(newValue) 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/TextLoader.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | class TextLoader: TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) { 10 | DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { 11 | completion("Cras mattis consectetur purus sit amet fermentum. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Aenean lacinia bibendum nulla sed consectetur. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.") 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/TextLoaderProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | protocol TextLoaderProtocol { 9 | func loadText(completion: @escaping (String)->Void) 10 | } 11 | 12 | protocol TextLoaderContainer { 13 | func makeTextLoader() -> TextLoaderProtocol 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVC/Wireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 17.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import Foundation 7 | 8 | typealias AppContext = TextLoaderContainer & MainViewContainer & NavigationControllerContainer & WindowContainer & DetailsViewContainer 9 | 10 | class Wireframe { 11 | 12 | let window: Window 13 | let navigationView: NavigationView 14 | let context: AppContext 15 | 16 | init(context: AppContext) { 17 | self.context = context 18 | 19 | window = context.makeWindow() 20 | 21 | navigationView = context.makeNavigationView() 22 | navigationView.views = [setupMainView()] 23 | 24 | window.rootView = navigationView 25 | window.install() 26 | } 27 | 28 | func setupMainView() -> MainViewProtocol { 29 | let view = context.makeMainView() 30 | let presenter = MainPresenter(textLoader: context.makeTextLoader(), view: view) 31 | view.presenter = presenter 32 | 33 | presenter.showDetails.subscribe {[unowned self, unowned presenter] in 34 | let vc = self.context.makeDetailsView(text: presenter.view.state.text ?? "WTF?") 35 | self.navigationView.pushView(view: vc, animated: true) 36 | } 37 | 38 | return view 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVCTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVCTests/SilverMVCTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VIPERTests.swift 3 | // VIPERTests 4 | // 5 | // Created by Pavel Sharanda on 20.11.16. 6 | // Copyright © 2016 psharanda. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class VIPERTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | let res = "Lorem Ipsum" 25 | 26 | var config = TestContext.Config() 27 | config.text = res 28 | 29 | let context = TestContext(config: config) 30 | 31 | let wireframe = Wireframe(context: context) 32 | 33 | 34 | let mainView = wireframe.navigationView.views[0] as! TestMainView 35 | mainView.loadClick.update() 36 | 37 | XCTAssertEqual(mainView.state.text, res) 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVCTests/TestContext.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 20.11.16. 3 | // Copyright © 2016 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class TestTextLoader: TextLoaderProtocol { 9 | let text: String 10 | init(text: String) { 11 | self.text = text 12 | } 13 | func loadText(completion: @escaping (String) -> Void) { 14 | completion(text) 15 | } 16 | } 17 | 18 | 19 | class TestMainView: TestView, MainViewProtocol { 20 | 21 | var loadClick = Signal() 22 | var detailsClick = Signal() 23 | 24 | var state = MainViewState() 25 | 26 | var viewController: UIViewController { 27 | fatalError() 28 | } 29 | } 30 | 31 | class TestDetailsView: TestView, DetailsViewProtocol { 32 | 33 | let text: String 34 | 35 | init(text: String) { 36 | self.text = text 37 | } 38 | 39 | var viewController: UIViewController { 40 | fatalError() 41 | } 42 | } 43 | 44 | class TestContext: AppContext { 45 | 46 | struct Config { 47 | var text = "Hello" 48 | } 49 | let config: Config 50 | init(config: Config) { 51 | self.config = config 52 | } 53 | 54 | func makeTextLoader() -> TextLoaderProtocol { 55 | return TestTextLoader(text: config.text) 56 | } 57 | 58 | func makeMainView() -> MainViewProtocol { 59 | return TestMainView() 60 | } 61 | 62 | func makeNavigationView() -> NavigationView { 63 | return TestNavigationView() 64 | } 65 | 66 | func makeWindow() -> Window { 67 | return TestWindow() 68 | } 69 | 70 | func makeDetailsView(text: String) -> DetailsViewProtocol { 71 | return TestDetailsView(text: text) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /7. SilverMVC/SilverMVCTests/TestRouting.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Pavel Sharanda on 23.02.17. 3 | // Copyright © 2017 psharanda. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class TestView { 9 | var presenter: AnyObject? 10 | } 11 | 12 | class TestNavigationView: TestView, NavigationView { 13 | func pushView(view: View, animated: Bool) { 14 | views.append(view) 15 | } 16 | 17 | func popView(view: View, animated: Bool) -> View? { 18 | return views.removeLast() 19 | } 20 | 21 | var views: [View] = [] 22 | 23 | var viewController: UIViewController { 24 | fatalError() 25 | } 26 | } 27 | 28 | class TestWindow: Window { 29 | var rootView: View? 30 | func install() { 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Pavel Sharanda 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # v=mc2 2 | Evolution of MVC on iOS with examples. 3 | 4 | ## Sample app 5 | App is very simple. It has just one button and one label. If user clicks button, app displays loading indicator and after a second displays some text. Also it has simple push navigation. 6 | 7 | ## 1. MassiveVC 8 | Massive View Controller is usual approach for most iOS apps, UIViewController does almost everything 9 | ## 2. ControllerVC 10 | Attempt to apply clean MVP arhitecture where UIViewController is Presenter (Controller). 11 | ## 3. VIPER aka 'MVP + Routing' 12 | Famous VIPER adopted to reality of our super complex app. UIViewController is View. 13 | ## 4. MVVM 14 | This is how Microsoft tech can be adopted to iOS + Routing. UIViewController is View. 15 | ## 5. MVP+Routing+Bindings 16 | Reactive VIPER (MVP+Routing) 17 | ## 6. MVVM+Bindings 18 | Reactive MVVM+Routing 19 | --------------------------------------------------------------------------------