├── README.md ├── SimpleMVVM.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── SimpleMVVM.xccheckout └── xcuserdata │ └── rafael.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── SimpleMVVM.xcscheme │ └── xcschememanagement.plist ├── SimpleMVVM ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── Model.h ├── Model.m ├── ViewController.h ├── ViewController.m ├── ViewModel.h ├── ViewModel.m └── main.m └── SimpleMVVMTests ├── Info.plist └── SimpleMVVMTests.m /README.md: -------------------------------------------------------------------------------- 1 | # Simple MVVM with singletons and KVC/KVO 2 | ============== 3 | 4 | A simple Objective-C MVVM example using singletons and KVC/KVO. 5 | 6 | ## Credits 7 | Developed by Rafael Colatusso - @colatusso. -------------------------------------------------------------------------------- /SimpleMVVM.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5311BA251B0A4B44000F39D0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5311BA241B0A4B44000F39D0 /* main.m */; }; 11 | 5311BA281B0A4B44000F39D0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5311BA271B0A4B44000F39D0 /* AppDelegate.m */; }; 12 | 5311BA2B1B0A4B44000F39D0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5311BA2A1B0A4B44000F39D0 /* ViewController.m */; }; 13 | 5311BA2E1B0A4B44000F39D0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5311BA2C1B0A4B44000F39D0 /* Main.storyboard */; }; 14 | 5311BA301B0A4B44000F39D0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5311BA2F1B0A4B44000F39D0 /* Images.xcassets */; }; 15 | 5311BA331B0A4B44000F39D0 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5311BA311B0A4B44000F39D0 /* LaunchScreen.xib */; }; 16 | 5311BA3F1B0A4B44000F39D0 /* SimpleMVVMTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5311BA3E1B0A4B44000F39D0 /* SimpleMVVMTests.m */; }; 17 | 5311BA4C1B0A4B61000F39D0 /* Model.m in Sources */ = {isa = PBXBuildFile; fileRef = 5311BA491B0A4B61000F39D0 /* Model.m */; }; 18 | 5311BA4D1B0A4B61000F39D0 /* ViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 5311BA4B1B0A4B61000F39D0 /* ViewModel.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 5311BA391B0A4B44000F39D0 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 5311BA171B0A4B44000F39D0 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 5311BA1E1B0A4B44000F39D0; 27 | remoteInfo = SimpleMVVM; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 5311BA1F1B0A4B44000F39D0 /* SimpleMVVM.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleMVVM.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 5311BA231B0A4B44000F39D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 5311BA241B0A4B44000F39D0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | 5311BA261B0A4B44000F39D0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 36 | 5311BA271B0A4B44000F39D0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 37 | 5311BA291B0A4B44000F39D0 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 38 | 5311BA2A1B0A4B44000F39D0 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 39 | 5311BA2D1B0A4B44000F39D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | 5311BA2F1B0A4B44000F39D0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | 5311BA321B0A4B44000F39D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 42 | 5311BA381B0A4B44000F39D0 /* SimpleMVVMTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleMVVMTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 5311BA3D1B0A4B44000F39D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 5311BA3E1B0A4B44000F39D0 /* SimpleMVVMTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleMVVMTests.m; sourceTree = ""; }; 45 | 5311BA481B0A4B61000F39D0 /* Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Model.h; sourceTree = ""; }; 46 | 5311BA491B0A4B61000F39D0 /* Model.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Model.m; sourceTree = ""; }; 47 | 5311BA4A1B0A4B61000F39D0 /* ViewModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewModel.h; sourceTree = ""; }; 48 | 5311BA4B1B0A4B61000F39D0 /* ViewModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewModel.m; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | 5311BA1C1B0A4B44000F39D0 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | 5311BA351B0A4B44000F39D0 /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 5311BA161B0A4B44000F39D0 = { 70 | isa = PBXGroup; 71 | children = ( 72 | 5311BA211B0A4B44000F39D0 /* SimpleMVVM */, 73 | 5311BA3B1B0A4B44000F39D0 /* SimpleMVVMTests */, 74 | 5311BA201B0A4B44000F39D0 /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 5311BA201B0A4B44000F39D0 /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 5311BA1F1B0A4B44000F39D0 /* SimpleMVVM.app */, 82 | 5311BA381B0A4B44000F39D0 /* SimpleMVVMTests.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | 5311BA211B0A4B44000F39D0 /* SimpleMVVM */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 5311BA261B0A4B44000F39D0 /* AppDelegate.h */, 91 | 5311BA271B0A4B44000F39D0 /* AppDelegate.m */, 92 | 5311BA291B0A4B44000F39D0 /* ViewController.h */, 93 | 5311BA2A1B0A4B44000F39D0 /* ViewController.m */, 94 | 5311BA481B0A4B61000F39D0 /* Model.h */, 95 | 5311BA491B0A4B61000F39D0 /* Model.m */, 96 | 5311BA4A1B0A4B61000F39D0 /* ViewModel.h */, 97 | 5311BA4B1B0A4B61000F39D0 /* ViewModel.m */, 98 | 5311BA2C1B0A4B44000F39D0 /* Main.storyboard */, 99 | 5311BA2F1B0A4B44000F39D0 /* Images.xcassets */, 100 | 5311BA311B0A4B44000F39D0 /* LaunchScreen.xib */, 101 | 5311BA221B0A4B44000F39D0 /* Supporting Files */, 102 | ); 103 | path = SimpleMVVM; 104 | sourceTree = ""; 105 | }; 106 | 5311BA221B0A4B44000F39D0 /* Supporting Files */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 5311BA231B0A4B44000F39D0 /* Info.plist */, 110 | 5311BA241B0A4B44000F39D0 /* main.m */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | 5311BA3B1B0A4B44000F39D0 /* SimpleMVVMTests */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 5311BA3E1B0A4B44000F39D0 /* SimpleMVVMTests.m */, 119 | 5311BA3C1B0A4B44000F39D0 /* Supporting Files */, 120 | ); 121 | path = SimpleMVVMTests; 122 | sourceTree = ""; 123 | }; 124 | 5311BA3C1B0A4B44000F39D0 /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 5311BA3D1B0A4B44000F39D0 /* Info.plist */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | /* End PBXGroup section */ 133 | 134 | /* Begin PBXNativeTarget section */ 135 | 5311BA1E1B0A4B44000F39D0 /* SimpleMVVM */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = 5311BA421B0A4B44000F39D0 /* Build configuration list for PBXNativeTarget "SimpleMVVM" */; 138 | buildPhases = ( 139 | 5311BA1B1B0A4B44000F39D0 /* Sources */, 140 | 5311BA1C1B0A4B44000F39D0 /* Frameworks */, 141 | 5311BA1D1B0A4B44000F39D0 /* Resources */, 142 | ); 143 | buildRules = ( 144 | ); 145 | dependencies = ( 146 | ); 147 | name = SimpleMVVM; 148 | productName = SimpleMVVM; 149 | productReference = 5311BA1F1B0A4B44000F39D0 /* SimpleMVVM.app */; 150 | productType = "com.apple.product-type.application"; 151 | }; 152 | 5311BA371B0A4B44000F39D0 /* SimpleMVVMTests */ = { 153 | isa = PBXNativeTarget; 154 | buildConfigurationList = 5311BA451B0A4B44000F39D0 /* Build configuration list for PBXNativeTarget "SimpleMVVMTests" */; 155 | buildPhases = ( 156 | 5311BA341B0A4B44000F39D0 /* Sources */, 157 | 5311BA351B0A4B44000F39D0 /* Frameworks */, 158 | 5311BA361B0A4B44000F39D0 /* Resources */, 159 | ); 160 | buildRules = ( 161 | ); 162 | dependencies = ( 163 | 5311BA3A1B0A4B44000F39D0 /* PBXTargetDependency */, 164 | ); 165 | name = SimpleMVVMTests; 166 | productName = SimpleMVVMTests; 167 | productReference = 5311BA381B0A4B44000F39D0 /* SimpleMVVMTests.xctest */; 168 | productType = "com.apple.product-type.bundle.unit-test"; 169 | }; 170 | /* End PBXNativeTarget section */ 171 | 172 | /* Begin PBXProject section */ 173 | 5311BA171B0A4B44000F39D0 /* Project object */ = { 174 | isa = PBXProject; 175 | attributes = { 176 | LastUpgradeCheck = 0630; 177 | ORGANIZATIONNAME = RightCloud; 178 | TargetAttributes = { 179 | 5311BA1E1B0A4B44000F39D0 = { 180 | CreatedOnToolsVersion = 6.3.1; 181 | }; 182 | 5311BA371B0A4B44000F39D0 = { 183 | CreatedOnToolsVersion = 6.3.1; 184 | TestTargetID = 5311BA1E1B0A4B44000F39D0; 185 | }; 186 | }; 187 | }; 188 | buildConfigurationList = 5311BA1A1B0A4B44000F39D0 /* Build configuration list for PBXProject "SimpleMVVM" */; 189 | compatibilityVersion = "Xcode 3.2"; 190 | developmentRegion = English; 191 | hasScannedForEncodings = 0; 192 | knownRegions = ( 193 | en, 194 | Base, 195 | ); 196 | mainGroup = 5311BA161B0A4B44000F39D0; 197 | productRefGroup = 5311BA201B0A4B44000F39D0 /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | 5311BA1E1B0A4B44000F39D0 /* SimpleMVVM */, 202 | 5311BA371B0A4B44000F39D0 /* SimpleMVVMTests */, 203 | ); 204 | }; 205 | /* End PBXProject section */ 206 | 207 | /* Begin PBXResourcesBuildPhase section */ 208 | 5311BA1D1B0A4B44000F39D0 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | 5311BA2E1B0A4B44000F39D0 /* Main.storyboard in Resources */, 213 | 5311BA331B0A4B44000F39D0 /* LaunchScreen.xib in Resources */, 214 | 5311BA301B0A4B44000F39D0 /* Images.xcassets in Resources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | 5311BA361B0A4B44000F39D0 /* Resources */ = { 219 | isa = PBXResourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | /* End PBXResourcesBuildPhase section */ 226 | 227 | /* Begin PBXSourcesBuildPhase section */ 228 | 5311BA1B1B0A4B44000F39D0 /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 5311BA2B1B0A4B44000F39D0 /* ViewController.m in Sources */, 233 | 5311BA281B0A4B44000F39D0 /* AppDelegate.m in Sources */, 234 | 5311BA4D1B0A4B61000F39D0 /* ViewModel.m in Sources */, 235 | 5311BA251B0A4B44000F39D0 /* main.m in Sources */, 236 | 5311BA4C1B0A4B61000F39D0 /* Model.m in Sources */, 237 | ); 238 | runOnlyForDeploymentPostprocessing = 0; 239 | }; 240 | 5311BA341B0A4B44000F39D0 /* Sources */ = { 241 | isa = PBXSourcesBuildPhase; 242 | buildActionMask = 2147483647; 243 | files = ( 244 | 5311BA3F1B0A4B44000F39D0 /* SimpleMVVMTests.m in Sources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | /* End PBXSourcesBuildPhase section */ 249 | 250 | /* Begin PBXTargetDependency section */ 251 | 5311BA3A1B0A4B44000F39D0 /* PBXTargetDependency */ = { 252 | isa = PBXTargetDependency; 253 | target = 5311BA1E1B0A4B44000F39D0 /* SimpleMVVM */; 254 | targetProxy = 5311BA391B0A4B44000F39D0 /* PBXContainerItemProxy */; 255 | }; 256 | /* End PBXTargetDependency section */ 257 | 258 | /* Begin PBXVariantGroup section */ 259 | 5311BA2C1B0A4B44000F39D0 /* Main.storyboard */ = { 260 | isa = PBXVariantGroup; 261 | children = ( 262 | 5311BA2D1B0A4B44000F39D0 /* Base */, 263 | ); 264 | name = Main.storyboard; 265 | sourceTree = ""; 266 | }; 267 | 5311BA311B0A4B44000F39D0 /* LaunchScreen.xib */ = { 268 | isa = PBXVariantGroup; 269 | children = ( 270 | 5311BA321B0A4B44000F39D0 /* Base */, 271 | ); 272 | name = LaunchScreen.xib; 273 | sourceTree = ""; 274 | }; 275 | /* End PBXVariantGroup section */ 276 | 277 | /* Begin XCBuildConfiguration section */ 278 | 5311BA401B0A4B44000F39D0 /* Debug */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ALWAYS_SEARCH_USER_PATHS = NO; 282 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 283 | CLANG_CXX_LIBRARY = "libc++"; 284 | CLANG_ENABLE_MODULES = YES; 285 | CLANG_ENABLE_OBJC_ARC = YES; 286 | CLANG_WARN_BOOL_CONVERSION = YES; 287 | CLANG_WARN_CONSTANT_CONVERSION = YES; 288 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 289 | CLANG_WARN_EMPTY_BODY = YES; 290 | CLANG_WARN_ENUM_CONVERSION = YES; 291 | CLANG_WARN_INT_CONVERSION = YES; 292 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 293 | CLANG_WARN_UNREACHABLE_CODE = YES; 294 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 295 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 296 | COPY_PHASE_STRIP = NO; 297 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 298 | ENABLE_STRICT_OBJC_MSGSEND = YES; 299 | GCC_C_LANGUAGE_STANDARD = gnu99; 300 | GCC_DYNAMIC_NO_PIC = NO; 301 | GCC_NO_COMMON_BLOCKS = YES; 302 | GCC_OPTIMIZATION_LEVEL = 0; 303 | GCC_PREPROCESSOR_DEFINITIONS = ( 304 | "DEBUG=1", 305 | "$(inherited)", 306 | ); 307 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 308 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 309 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 310 | GCC_WARN_UNDECLARED_SELECTOR = YES; 311 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 312 | GCC_WARN_UNUSED_FUNCTION = YES; 313 | GCC_WARN_UNUSED_VARIABLE = YES; 314 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 315 | MTL_ENABLE_DEBUG_INFO = YES; 316 | ONLY_ACTIVE_ARCH = YES; 317 | SDKROOT = iphoneos; 318 | TARGETED_DEVICE_FAMILY = "1,2"; 319 | }; 320 | name = Debug; 321 | }; 322 | 5311BA411B0A4B44000F39D0 /* Release */ = { 323 | isa = XCBuildConfiguration; 324 | buildSettings = { 325 | ALWAYS_SEARCH_USER_PATHS = NO; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BOOL_CONVERSION = YES; 331 | CLANG_WARN_CONSTANT_CONVERSION = YES; 332 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 333 | CLANG_WARN_EMPTY_BODY = YES; 334 | CLANG_WARN_ENUM_CONVERSION = YES; 335 | CLANG_WARN_INT_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 337 | CLANG_WARN_UNREACHABLE_CODE = YES; 338 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 339 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 340 | COPY_PHASE_STRIP = NO; 341 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 342 | ENABLE_NS_ASSERTIONS = NO; 343 | ENABLE_STRICT_OBJC_MSGSEND = YES; 344 | GCC_C_LANGUAGE_STANDARD = gnu99; 345 | GCC_NO_COMMON_BLOCKS = YES; 346 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 347 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 348 | GCC_WARN_UNDECLARED_SELECTOR = YES; 349 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 350 | GCC_WARN_UNUSED_FUNCTION = YES; 351 | GCC_WARN_UNUSED_VARIABLE = YES; 352 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 353 | MTL_ENABLE_DEBUG_INFO = NO; 354 | SDKROOT = iphoneos; 355 | TARGETED_DEVICE_FAMILY = "1,2"; 356 | VALIDATE_PRODUCT = YES; 357 | }; 358 | name = Release; 359 | }; 360 | 5311BA431B0A4B44000F39D0 /* Debug */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 364 | INFOPLIST_FILE = SimpleMVVM/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 366 | PRODUCT_NAME = "$(TARGET_NAME)"; 367 | }; 368 | name = Debug; 369 | }; 370 | 5311BA441B0A4B44000F39D0 /* Release */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 374 | INFOPLIST_FILE = SimpleMVVM/Info.plist; 375 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 376 | PRODUCT_NAME = "$(TARGET_NAME)"; 377 | }; 378 | name = Release; 379 | }; 380 | 5311BA461B0A4B44000F39D0 /* Debug */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | BUNDLE_LOADER = "$(TEST_HOST)"; 384 | FRAMEWORK_SEARCH_PATHS = ( 385 | "$(SDKROOT)/Developer/Library/Frameworks", 386 | "$(inherited)", 387 | ); 388 | GCC_PREPROCESSOR_DEFINITIONS = ( 389 | "DEBUG=1", 390 | "$(inherited)", 391 | ); 392 | INFOPLIST_FILE = SimpleMVVMTests/Info.plist; 393 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 394 | PRODUCT_NAME = "$(TARGET_NAME)"; 395 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleMVVM.app/SimpleMVVM"; 396 | }; 397 | name = Debug; 398 | }; 399 | 5311BA471B0A4B44000F39D0 /* Release */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | BUNDLE_LOADER = "$(TEST_HOST)"; 403 | FRAMEWORK_SEARCH_PATHS = ( 404 | "$(SDKROOT)/Developer/Library/Frameworks", 405 | "$(inherited)", 406 | ); 407 | INFOPLIST_FILE = SimpleMVVMTests/Info.plist; 408 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleMVVM.app/SimpleMVVM"; 411 | }; 412 | name = Release; 413 | }; 414 | /* End XCBuildConfiguration section */ 415 | 416 | /* Begin XCConfigurationList section */ 417 | 5311BA1A1B0A4B44000F39D0 /* Build configuration list for PBXProject "SimpleMVVM" */ = { 418 | isa = XCConfigurationList; 419 | buildConfigurations = ( 420 | 5311BA401B0A4B44000F39D0 /* Debug */, 421 | 5311BA411B0A4B44000F39D0 /* Release */, 422 | ); 423 | defaultConfigurationIsVisible = 0; 424 | defaultConfigurationName = Release; 425 | }; 426 | 5311BA421B0A4B44000F39D0 /* Build configuration list for PBXNativeTarget "SimpleMVVM" */ = { 427 | isa = XCConfigurationList; 428 | buildConfigurations = ( 429 | 5311BA431B0A4B44000F39D0 /* Debug */, 430 | 5311BA441B0A4B44000F39D0 /* Release */, 431 | ); 432 | defaultConfigurationIsVisible = 0; 433 | }; 434 | 5311BA451B0A4B44000F39D0 /* Build configuration list for PBXNativeTarget "SimpleMVVMTests" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 5311BA461B0A4B44000F39D0 /* Debug */, 438 | 5311BA471B0A4B44000F39D0 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | }; 442 | /* End XCConfigurationList section */ 443 | }; 444 | rootObject = 5311BA171B0A4B44000F39D0 /* Project object */; 445 | } 446 | -------------------------------------------------------------------------------- /SimpleMVVM.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SimpleMVVM.xcodeproj/project.xcworkspace/xcshareddata/SimpleMVVM.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 87FD9565-3007-4298-84B3-843E50C1408A 9 | IDESourceControlProjectName 10 | SimpleMVVM 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 99DD0675D44F78AD4CE31DB46CB019A8D16B6111 14 | https://github.com/colatusso/SimpleMVVM.git 15 | 16 | IDESourceControlProjectPath 17 | SimpleMVVM.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 99DD0675D44F78AD4CE31DB46CB019A8D16B6111 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/colatusso/SimpleMVVM.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 99DD0675D44F78AD4CE31DB46CB019A8D16B6111 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 99DD0675D44F78AD4CE31DB46CB019A8D16B6111 36 | IDESourceControlWCCName 37 | SimpleMVVM 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SimpleMVVM.xcodeproj/xcuserdata/rafael.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SimpleMVVM.xcodeproj/xcuserdata/rafael.xcuserdatad/xcschemes/SimpleMVVM.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /SimpleMVVM.xcodeproj/xcuserdata/rafael.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SimpleMVVM.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 5311BA1E1B0A4B44000F39D0 16 | 17 | primary 18 | 19 | 20 | 5311BA371B0A4B44000F39D0 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SimpleMVVM/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SimpleMVVM/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /SimpleMVVM/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SimpleMVVM/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /SimpleMVVM/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SimpleMVVM/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | br.com.rightcloud.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SimpleMVVM/Model.h: -------------------------------------------------------------------------------- 1 | // 2 | // Model.h 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Model : NSObject 12 | 13 | + (id)sharedInstance; 14 | - (void)loadData; 15 | - (void)setNewData; 16 | 17 | @property (strong, nonatomic) NSArray *dataArray; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /SimpleMVVM/Model.m: -------------------------------------------------------------------------------- 1 | // 2 | // Model.m 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import "Model.h" 10 | 11 | @implementation Model 12 | 13 | + (id)sharedInstance { 14 | // this prevents duplicated instances and create a shared one 15 | // ideal when working with databases 16 | 17 | static Model *data = nil; 18 | static dispatch_once_t onceToken; 19 | 20 | dispatch_once(&onceToken, ^{ 21 | data = [[self alloc] init]; 22 | }); 23 | 24 | return data; 25 | } 26 | 27 | - (id)init { 28 | self = [super init]; 29 | 30 | if (self) { 31 | // loading the initial data via KVC 32 | [self loadData]; 33 | 34 | // do your initialization stuff here 35 | 36 | } 37 | 38 | return self; 39 | } 40 | 41 | - (void)loadData { 42 | // setting the initial data, observed with NSKeyValueObservingOptionInitial 43 | [self setValue:@[@"first", @"second", @"third"] forKey:@"dataArray"]; 44 | } 45 | 46 | - (void)setNewData { 47 | [self setValue:@[@"FIRST", @"SECOND", @"THIRD"] forKey:@"dataArray"]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /SimpleMVVM/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (strong, nonatomic) IBOutlet UITableView *tableView; 14 | @property (strong, nonatomic) NSArray *data; 15 | 16 | 17 | 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /SimpleMVVM/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "ViewModel.h" 11 | #import "Model.h" 12 | 13 | @interface ViewController () 14 | 15 | @property (strong, nonatomic) ViewModel *viewModel; 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | // shared ViewModel instance intialization 25 | // without KVC/KVO (first commit) the data would have been loaded inside the ViewModel class 26 | self.viewModel = [ViewModel sharedInstanceWithViewController:self]; 27 | 28 | self.tableView.dataSource = self; 29 | self.tableView.delegate = self; 30 | 31 | // observing the property for changes 32 | [self.viewModel.model addObserver:self forKeyPath:@"dataArray" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:nil]; 33 | } 34 | 35 | - (void)viewWillDisappear:(BOOL)animated { 36 | // removing the observer 37 | [self.viewModel.model removeObserver:self forKeyPath:@"dataArray"]; 38 | } 39 | 40 | #pragma mark - tableview controller 41 | 42 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 43 | return 1; 44 | } 45 | 46 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 47 | return self.data.count; 48 | } 49 | 50 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 51 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; 52 | 53 | if (cell == nil) { 54 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 55 | } 56 | 57 | cell.textLabel.text = [self.data objectAtIndex:indexPath.row]; 58 | 59 | return cell; 60 | } 61 | 62 | #pragma mark - observer 63 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 64 | NSLog(@"new data: %@", change); 65 | self.data = [change objectForKey:@"new"]; 66 | [self.tableView reloadData]; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /SimpleMVVM/ViewModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewModel.h 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ViewController.h" 11 | #import "Model.h" 12 | 13 | @class UIViewController; 14 | 15 | @interface ViewModel : NSObject 16 | 17 | + (id)sharedInstanceWithViewController:(ViewController *)viewController; 18 | @property (strong, nonatomic) ViewController *viewController; 19 | @property (strong, nonatomic) Model *model; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /SimpleMVVM/ViewModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewModel.m 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import "ViewModel.h" 10 | #import "Model.h" 11 | 12 | @interface ViewModel () 13 | 14 | @end 15 | 16 | @implementation ViewModel 17 | 18 | + (id)sharedInstanceWithViewController:(ViewController *)viewController { 19 | // this prevents duplicated instances and create a shared one 20 | 21 | static ViewModel *viewModel = nil; 22 | static dispatch_once_t onceToken; 23 | 24 | dispatch_once(&onceToken, ^{ 25 | viewModel = [[self alloc] initWithViewController:(ViewController *)viewController]; 26 | }); 27 | 28 | return viewModel; 29 | } 30 | 31 | - (id) initWithViewController:(ViewController*)viewController { 32 | self = [super init]; 33 | 34 | if (self) { 35 | self.viewController = viewController; 36 | 37 | /* 38 | normally you would set the initial data here, but since I added KVC/KVO NSKeyValueObservingOptionInitial there is no need for this, but it would be like: 39 | self.viewController.data = [self.model methodThatReturnsData]; 40 | */ 41 | 42 | // shared instance of the model, the data is lodaded inside the class initialization 43 | self.model = [Model sharedInstance]; 44 | 45 | // setting new values after 3 seconds, just for the sake of this example! Observed with NSKeyValueObservingOptionNew 46 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 47 | [self.model setNewData]; 48 | }); 49 | } 50 | 51 | return self; 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /SimpleMVVM/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleMVVM 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SimpleMVVMTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | br.com.rightcloud.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SimpleMVVMTests/SimpleMVVMTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleMVVMTests.m 3 | // SimpleMVVMTests 4 | // 5 | // Created by Rafael on 18/05/15. 6 | // Copyright (c) 2015 RightCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface SimpleMVVMTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation SimpleMVVMTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------