├── .gitignore ├── MVVM-DataController-Demo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── skyline.xcuserdatad │ └── xcschemes │ ├── MVVM-DataController-Demo.xcscheme │ └── xcschememanagement.plist ├── MVVM-DataController-Demo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── LaunchScreen.storyboard ├── DataController │ ├── JLBaseDataController.h │ ├── JLBaseDataController.m │ ├── JLHomePracticeDataController.h │ ├── JLHomePracticeDataController.m │ ├── JLSubjectDataController.h │ └── JLSubjectDataController.m ├── Info.plist ├── Model │ ├── JLSubject.h │ └── JLSubject.m ├── Supporting Files │ └── main.m ├── View │ ├── JLHomePracticeActivityView.h │ ├── JLHomePracticeActivityView.m │ ├── JLHomePracticeBannerView.h │ ├── JLHomePracticeBannerView.m │ ├── JLHomePracticeSubjectsCollectionViewCell.h │ ├── JLHomePracticeSubjectsCollectionViewCell.m │ ├── JLHomePracticeSubjectsView.h │ └── JLHomePracticeSubjectsView.m ├── ViewController │ ├── JLHomePracticeViewController.h │ └── JLHomePracticeViewController.m └── ViewModel │ ├── JLHomePracticeSubjectsCollectionCellViewModel.h │ ├── JLHomePracticeSubjectsCollectionCellViewModel.m │ ├── JLHomePracticeSubjectsViewModel.h │ └── JLHomePracticeSubjectsViewModel.m ├── README.md └── arch.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | .DS_Store 4 | build/ 5 | *.pbxuser 6 | *.mode1v3 7 | *.mode2v3 8 | *.perspectivev3 9 | xcuserdata 10 | *.xccheckout 11 | *.moved-aside 12 | DerivedData 13 | *.hmap 14 | *.ipa 15 | *.zip 16 | *.xcuserstate 17 | *.xcworkspace 18 | 19 | # CocoaPods 20 | # 21 | Pods/ 22 | Podfile.lock 23 | Pods-Acknowledgements.plist 24 | 25 | # AppCode 26 | .idea/ 27 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 2D0089611C9807830018B833 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089601C9807830018B833 /* main.m */; }; 11 | 2D0089641C9807830018B833 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089631C9807830018B833 /* AppDelegate.m */; }; 12 | 2D00896C1C9807830018B833 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2D00896B1C9807830018B833 /* Assets.xcassets */; }; 13 | 2D00896F1C9807830018B833 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2D00896D1C9807830018B833 /* LaunchScreen.storyboard */; }; 14 | 2D00897D1C98087C0018B833 /* JLHomePracticeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D00897C1C98087C0018B833 /* JLHomePracticeViewController.m */; }; 15 | 2D0089801C9808FD0018B833 /* JLHomePracticeBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D00897F1C9808FD0018B833 /* JLHomePracticeBannerView.m */; }; 16 | 2D0089831C98090E0018B833 /* JLHomePracticeActivityView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089821C98090E0018B833 /* JLHomePracticeActivityView.m */; }; 17 | 2D0089861C98092A0018B833 /* JLHomePracticeSubjectsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089851C98092A0018B833 /* JLHomePracticeSubjectsView.m */; }; 18 | 2D0089891C980A990018B833 /* JLBaseDataController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089881C980A990018B833 /* JLBaseDataController.m */; }; 19 | 2D00898C1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D00898B1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.m */; }; 20 | 2D00898F1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D00898E1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.m */; }; 21 | 2D0089921C980BDF0018B833 /* JLSubject.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089911C980BDF0018B833 /* JLSubject.m */; }; 22 | 2D0089951C980CF50018B833 /* JLHomePracticeSubjectsViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089941C980CF50018B833 /* JLHomePracticeSubjectsViewModel.m */; }; 23 | 2D0089981C98110F0018B833 /* JLHomePracticeDataController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D0089971C98110F0018B833 /* JLHomePracticeDataController.m */; }; 24 | 2D00899B1C98113F0018B833 /* JLSubjectDataController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D00899A1C98113F0018B833 /* JLSubjectDataController.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 2D00895C1C9807830018B833 /* MVVM-DataController-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MVVM-DataController-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 2D0089601C9807830018B833 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 2D0089621C9807830018B833 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 31 | 2D0089631C9807830018B833 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 32 | 2D00896B1C9807830018B833 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 33 | 2D00896E1C9807830018B833 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 34 | 2D0089701C9807830018B833 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 35 | 2D00897B1C98087C0018B833 /* JLHomePracticeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeViewController.h; sourceTree = ""; }; 36 | 2D00897C1C98087C0018B833 /* JLHomePracticeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeViewController.m; sourceTree = ""; }; 37 | 2D00897E1C9808FD0018B833 /* JLHomePracticeBannerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeBannerView.h; sourceTree = ""; }; 38 | 2D00897F1C9808FD0018B833 /* JLHomePracticeBannerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeBannerView.m; sourceTree = ""; }; 39 | 2D0089811C98090E0018B833 /* JLHomePracticeActivityView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeActivityView.h; sourceTree = ""; }; 40 | 2D0089821C98090E0018B833 /* JLHomePracticeActivityView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeActivityView.m; sourceTree = ""; }; 41 | 2D0089841C98092A0018B833 /* JLHomePracticeSubjectsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeSubjectsView.h; sourceTree = ""; }; 42 | 2D0089851C98092A0018B833 /* JLHomePracticeSubjectsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeSubjectsView.m; sourceTree = ""; }; 43 | 2D0089871C980A990018B833 /* JLBaseDataController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLBaseDataController.h; sourceTree = ""; }; 44 | 2D0089881C980A990018B833 /* JLBaseDataController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLBaseDataController.m; sourceTree = ""; }; 45 | 2D00898A1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeSubjectsCollectionViewCell.h; sourceTree = ""; }; 46 | 2D00898B1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeSubjectsCollectionViewCell.m; sourceTree = ""; }; 47 | 2D00898D1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeSubjectsCollectionCellViewModel.h; sourceTree = ""; }; 48 | 2D00898E1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeSubjectsCollectionCellViewModel.m; sourceTree = ""; }; 49 | 2D0089901C980BDF0018B833 /* JLSubject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLSubject.h; sourceTree = ""; }; 50 | 2D0089911C980BDF0018B833 /* JLSubject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLSubject.m; sourceTree = ""; }; 51 | 2D0089931C980CF50018B833 /* JLHomePracticeSubjectsViewModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeSubjectsViewModel.h; sourceTree = ""; }; 52 | 2D0089941C980CF50018B833 /* JLHomePracticeSubjectsViewModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeSubjectsViewModel.m; sourceTree = ""; }; 53 | 2D0089961C98110F0018B833 /* JLHomePracticeDataController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLHomePracticeDataController.h; sourceTree = ""; }; 54 | 2D0089971C98110F0018B833 /* JLHomePracticeDataController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLHomePracticeDataController.m; sourceTree = ""; }; 55 | 2D0089991C98113F0018B833 /* JLSubjectDataController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JLSubjectDataController.h; sourceTree = ""; }; 56 | 2D00899A1C98113F0018B833 /* JLSubjectDataController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JLSubjectDataController.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 2D0089591C9807830018B833 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 2D0089531C9807830018B833 = { 71 | isa = PBXGroup; 72 | children = ( 73 | 2D00895E1C9807830018B833 /* MVVM-DataController-Demo */, 74 | 2D00895D1C9807830018B833 /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 2D00895D1C9807830018B833 /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 2D00895C1C9807830018B833 /* MVVM-DataController-Demo.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 2D00895E1C9807830018B833 /* MVVM-DataController-Demo */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 2D0089791C9808440018B833 /* DataController */, 90 | 2D0089781C98083E0018B833 /* Model */, 91 | 2D00895F1C9807830018B833 /* Supporting Files */, 92 | 2D0089761C98082D0018B833 /* View */, 93 | 2D00897A1C98085A0018B833 /* ViewController */, 94 | 2D0089771C9808330018B833 /* ViewModel */, 95 | 2D0089621C9807830018B833 /* AppDelegate.h */, 96 | 2D0089631C9807830018B833 /* AppDelegate.m */, 97 | 2D00896B1C9807830018B833 /* Assets.xcassets */, 98 | 2D0089701C9807830018B833 /* Info.plist */, 99 | 2D00896D1C9807830018B833 /* LaunchScreen.storyboard */, 100 | ); 101 | path = "MVVM-DataController-Demo"; 102 | sourceTree = ""; 103 | }; 104 | 2D00895F1C9807830018B833 /* Supporting Files */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 2D0089601C9807830018B833 /* main.m */, 108 | ); 109 | path = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 2D0089761C98082D0018B833 /* View */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 2D0089811C98090E0018B833 /* JLHomePracticeActivityView.h */, 116 | 2D0089821C98090E0018B833 /* JLHomePracticeActivityView.m */, 117 | 2D00897E1C9808FD0018B833 /* JLHomePracticeBannerView.h */, 118 | 2D00897F1C9808FD0018B833 /* JLHomePracticeBannerView.m */, 119 | 2D00898A1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.h */, 120 | 2D00898B1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.m */, 121 | 2D0089841C98092A0018B833 /* JLHomePracticeSubjectsView.h */, 122 | 2D0089851C98092A0018B833 /* JLHomePracticeSubjectsView.m */, 123 | ); 124 | path = View; 125 | sourceTree = ""; 126 | }; 127 | 2D0089771C9808330018B833 /* ViewModel */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 2D00898D1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.h */, 131 | 2D00898E1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.m */, 132 | 2D0089931C980CF50018B833 /* JLHomePracticeSubjectsViewModel.h */, 133 | 2D0089941C980CF50018B833 /* JLHomePracticeSubjectsViewModel.m */, 134 | ); 135 | path = ViewModel; 136 | sourceTree = ""; 137 | }; 138 | 2D0089781C98083E0018B833 /* Model */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 2D0089901C980BDF0018B833 /* JLSubject.h */, 142 | 2D0089911C980BDF0018B833 /* JLSubject.m */, 143 | ); 144 | path = Model; 145 | sourceTree = ""; 146 | }; 147 | 2D0089791C9808440018B833 /* DataController */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 2D0089871C980A990018B833 /* JLBaseDataController.h */, 151 | 2D0089881C980A990018B833 /* JLBaseDataController.m */, 152 | 2D0089961C98110F0018B833 /* JLHomePracticeDataController.h */, 153 | 2D0089971C98110F0018B833 /* JLHomePracticeDataController.m */, 154 | 2D0089991C98113F0018B833 /* JLSubjectDataController.h */, 155 | 2D00899A1C98113F0018B833 /* JLSubjectDataController.m */, 156 | ); 157 | path = DataController; 158 | sourceTree = ""; 159 | }; 160 | 2D00897A1C98085A0018B833 /* ViewController */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | 2D00897B1C98087C0018B833 /* JLHomePracticeViewController.h */, 164 | 2D00897C1C98087C0018B833 /* JLHomePracticeViewController.m */, 165 | ); 166 | path = ViewController; 167 | sourceTree = ""; 168 | }; 169 | /* End PBXGroup section */ 170 | 171 | /* Begin PBXNativeTarget section */ 172 | 2D00895B1C9807830018B833 /* MVVM-DataController-Demo */ = { 173 | isa = PBXNativeTarget; 174 | buildConfigurationList = 2D0089731C9807830018B833 /* Build configuration list for PBXNativeTarget "MVVM-DataController-Demo" */; 175 | buildPhases = ( 176 | 2D0089581C9807830018B833 /* Sources */, 177 | 2D0089591C9807830018B833 /* Frameworks */, 178 | 2D00895A1C9807830018B833 /* Resources */, 179 | ); 180 | buildRules = ( 181 | ); 182 | dependencies = ( 183 | ); 184 | name = "MVVM-DataController-Demo"; 185 | productName = "MVVM-DataController-Demo"; 186 | productReference = 2D00895C1C9807830018B833 /* MVVM-DataController-Demo.app */; 187 | productType = "com.apple.product-type.application"; 188 | }; 189 | /* End PBXNativeTarget section */ 190 | 191 | /* Begin PBXProject section */ 192 | 2D0089541C9807830018B833 /* Project object */ = { 193 | isa = PBXProject; 194 | attributes = { 195 | LastUpgradeCheck = 1120; 196 | ORGANIZATIONNAME = skyline; 197 | TargetAttributes = { 198 | 2D00895B1C9807830018B833 = { 199 | CreatedOnToolsVersion = 7.2.1; 200 | }; 201 | }; 202 | }; 203 | buildConfigurationList = 2D0089571C9807830018B833 /* Build configuration list for PBXProject "MVVM-DataController-Demo" */; 204 | compatibilityVersion = "Xcode 3.2"; 205 | developmentRegion = en; 206 | hasScannedForEncodings = 0; 207 | knownRegions = ( 208 | en, 209 | Base, 210 | ); 211 | mainGroup = 2D0089531C9807830018B833; 212 | productRefGroup = 2D00895D1C9807830018B833 /* Products */; 213 | projectDirPath = ""; 214 | projectRoot = ""; 215 | targets = ( 216 | 2D00895B1C9807830018B833 /* MVVM-DataController-Demo */, 217 | ); 218 | }; 219 | /* End PBXProject section */ 220 | 221 | /* Begin PBXResourcesBuildPhase section */ 222 | 2D00895A1C9807830018B833 /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 2D00896F1C9807830018B833 /* LaunchScreen.storyboard in Resources */, 227 | 2D00896C1C9807830018B833 /* Assets.xcassets in Resources */, 228 | ); 229 | runOnlyForDeploymentPostprocessing = 0; 230 | }; 231 | /* End PBXResourcesBuildPhase section */ 232 | 233 | /* Begin PBXSourcesBuildPhase section */ 234 | 2D0089581C9807830018B833 /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 2D0089891C980A990018B833 /* JLBaseDataController.m in Sources */, 239 | 2D0089801C9808FD0018B833 /* JLHomePracticeBannerView.m in Sources */, 240 | 2D00898C1C980B930018B833 /* JLHomePracticeSubjectsCollectionViewCell.m in Sources */, 241 | 2D0089951C980CF50018B833 /* JLHomePracticeSubjectsViewModel.m in Sources */, 242 | 2D0089861C98092A0018B833 /* JLHomePracticeSubjectsView.m in Sources */, 243 | 2D0089921C980BDF0018B833 /* JLSubject.m in Sources */, 244 | 2D0089831C98090E0018B833 /* JLHomePracticeActivityView.m in Sources */, 245 | 2D00898F1C980BBB0018B833 /* JLHomePracticeSubjectsCollectionCellViewModel.m in Sources */, 246 | 2D0089641C9807830018B833 /* AppDelegate.m in Sources */, 247 | 2D00899B1C98113F0018B833 /* JLSubjectDataController.m in Sources */, 248 | 2D00897D1C98087C0018B833 /* JLHomePracticeViewController.m in Sources */, 249 | 2D0089981C98110F0018B833 /* JLHomePracticeDataController.m in Sources */, 250 | 2D0089611C9807830018B833 /* main.m in Sources */, 251 | ); 252 | runOnlyForDeploymentPostprocessing = 0; 253 | }; 254 | /* End PBXSourcesBuildPhase section */ 255 | 256 | /* Begin PBXVariantGroup section */ 257 | 2D00896D1C9807830018B833 /* LaunchScreen.storyboard */ = { 258 | isa = PBXVariantGroup; 259 | children = ( 260 | 2D00896E1C9807830018B833 /* Base */, 261 | ); 262 | name = LaunchScreen.storyboard; 263 | path = .; 264 | sourceTree = ""; 265 | }; 266 | /* End PBXVariantGroup section */ 267 | 268 | /* Begin XCBuildConfiguration section */ 269 | 2D0089711C9807830018B833 /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ALWAYS_SEARCH_USER_PATHS = NO; 273 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 274 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 275 | CLANG_CXX_LIBRARY = "libc++"; 276 | CLANG_ENABLE_MODULES = YES; 277 | CLANG_ENABLE_OBJC_ARC = YES; 278 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 279 | CLANG_WARN_BOOL_CONVERSION = YES; 280 | CLANG_WARN_COMMA = YES; 281 | CLANG_WARN_CONSTANT_CONVERSION = YES; 282 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 283 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 284 | CLANG_WARN_EMPTY_BODY = YES; 285 | CLANG_WARN_ENUM_CONVERSION = YES; 286 | CLANG_WARN_INFINITE_RECURSION = YES; 287 | CLANG_WARN_INT_CONVERSION = YES; 288 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 289 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 290 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 291 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 292 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 293 | CLANG_WARN_STRICT_PROTOTYPES = YES; 294 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 295 | CLANG_WARN_UNREACHABLE_CODE = YES; 296 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 297 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 298 | COPY_PHASE_STRIP = NO; 299 | DEBUG_INFORMATION_FORMAT = dwarf; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | ENABLE_TESTABILITY = YES; 302 | GCC_C_LANGUAGE_STANDARD = gnu99; 303 | GCC_DYNAMIC_NO_PIC = NO; 304 | GCC_NO_COMMON_BLOCKS = YES; 305 | GCC_OPTIMIZATION_LEVEL = 0; 306 | GCC_PREPROCESSOR_DEFINITIONS = ( 307 | "DEBUG=1", 308 | "$(inherited)", 309 | ); 310 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 311 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 312 | GCC_WARN_UNDECLARED_SELECTOR = YES; 313 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 314 | GCC_WARN_UNUSED_FUNCTION = YES; 315 | GCC_WARN_UNUSED_VARIABLE = YES; 316 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 317 | MTL_ENABLE_DEBUG_INFO = YES; 318 | ONLY_ACTIVE_ARCH = YES; 319 | SDKROOT = iphoneos; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | }; 322 | name = Debug; 323 | }; 324 | 2D0089721C9807830018B833 /* Release */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 330 | CLANG_CXX_LIBRARY = "libc++"; 331 | CLANG_ENABLE_MODULES = YES; 332 | CLANG_ENABLE_OBJC_ARC = YES; 333 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 334 | CLANG_WARN_BOOL_CONVERSION = YES; 335 | CLANG_WARN_COMMA = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 338 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 339 | CLANG_WARN_EMPTY_BODY = YES; 340 | CLANG_WARN_ENUM_CONVERSION = YES; 341 | CLANG_WARN_INFINITE_RECURSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 345 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 346 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 347 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 348 | CLANG_WARN_STRICT_PROTOTYPES = YES; 349 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 350 | CLANG_WARN_UNREACHABLE_CODE = YES; 351 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 352 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 353 | COPY_PHASE_STRIP = NO; 354 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 355 | ENABLE_NS_ASSERTIONS = NO; 356 | ENABLE_STRICT_OBJC_MSGSEND = YES; 357 | GCC_C_LANGUAGE_STANDARD = gnu99; 358 | GCC_NO_COMMON_BLOCKS = YES; 359 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 360 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 361 | GCC_WARN_UNDECLARED_SELECTOR = YES; 362 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 363 | GCC_WARN_UNUSED_FUNCTION = YES; 364 | GCC_WARN_UNUSED_VARIABLE = YES; 365 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 366 | MTL_ENABLE_DEBUG_INFO = NO; 367 | SDKROOT = iphoneos; 368 | TARGETED_DEVICE_FAMILY = "1,2"; 369 | VALIDATE_PRODUCT = YES; 370 | }; 371 | name = Release; 372 | }; 373 | 2D0089741C9807830018B833 /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 377 | INFOPLIST_FILE = "MVVM-DataController-Demo/Info.plist"; 378 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 379 | PRODUCT_BUNDLE_IDENTIFIER = "cn.edu.hit.MVVM-DataController-Demo"; 380 | PRODUCT_NAME = "$(TARGET_NAME)"; 381 | }; 382 | name = Debug; 383 | }; 384 | 2D0089751C9807830018B833 /* Release */ = { 385 | isa = XCBuildConfiguration; 386 | buildSettings = { 387 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 388 | INFOPLIST_FILE = "MVVM-DataController-Demo/Info.plist"; 389 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 390 | PRODUCT_BUNDLE_IDENTIFIER = "cn.edu.hit.MVVM-DataController-Demo"; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | }; 393 | name = Release; 394 | }; 395 | /* End XCBuildConfiguration section */ 396 | 397 | /* Begin XCConfigurationList section */ 398 | 2D0089571C9807830018B833 /* Build configuration list for PBXProject "MVVM-DataController-Demo" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | 2D0089711C9807830018B833 /* Debug */, 402 | 2D0089721C9807830018B833 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | 2D0089731C9807830018B833 /* Build configuration list for PBXNativeTarget "MVVM-DataController-Demo" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | 2D0089741C9807830018B833 /* Debug */, 411 | 2D0089751C9807830018B833 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | /* End XCConfigurationList section */ 417 | }; 418 | rootObject = 2D0089541C9807830018B833 /* Project object */; 419 | } 420 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo.xcodeproj/xcuserdata/skyline.xcuserdatad/xcschemes/MVVM-DataController-Demo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo.xcodeproj/xcuserdata/skyline.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MVVM-DataController-Demo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 2D00895B1C9807830018B833 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. 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 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "JLHomePracticeViewController.h" 11 | 12 | @interface AppDelegate () 13 | 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | // Override point for customization after application launch. 21 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 22 | JLHomePracticeViewController *vc = [[JLHomePracticeViewController alloc] init]; 23 | self.window.rootViewController = vc; 24 | 25 | [self.window makeKeyAndVisible]; 26 | return YES; 27 | } 28 | 29 | - (void)applicationWillResignActive:(UIApplication *)application { 30 | // 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. 31 | // 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. 32 | } 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application { 35 | // 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. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | - (void)applicationWillEnterForeground:(UIApplication *)application { 40 | // 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. 41 | } 42 | 43 | - (void)applicationDidBecomeActive:(UIApplication *)application { 44 | // 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. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/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 | "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 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /MVVM-DataController-Demo/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 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/DataController/JLBaseDataController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLBaseDataController.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void (^JLCompletionCallback)(NSError *); 12 | 13 | @interface JLBaseDataController : NSObject 14 | 15 | /** 网络请求,供子类调用*/ 16 | - (void)requestWithDataType:(NSString *)type; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/DataController/JLBaseDataController.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLBaseDataController.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLBaseDataController.h" 10 | 11 | @implementation JLBaseDataController 12 | 13 | - (void)requestWithDataType:(NSString *)type { 14 | 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/DataController/JLHomePracticeDataController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeDataController.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLBaseDataController.h" 10 | #import "JLSubject.h" 11 | 12 | @interface JLHomePracticeDataController : JLBaseDataController 13 | 14 | @property (nonatomic, strong, nullable) NSArray *openSubjects; 15 | 16 | - (void)requestSubjectDataWithCallback:(nonnull JLCompletionCallback)callback; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/DataController/JLHomePracticeDataController.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeDataController.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeDataController.h" 10 | #import "JLSubjectDataController.h" 11 | 12 | @interface JLHomePracticeDataController () 13 | 14 | @property (nonatomic, strong, nonnull) JLSubjectDataController *subjectDataController; 15 | 16 | @end 17 | 18 | @implementation JLHomePracticeDataController 19 | 20 | - (instancetype)init { 21 | self = [super init]; 22 | if (self) { 23 | _subjectDataController = [[JLSubjectDataController alloc] init]; 24 | } 25 | return self; 26 | } 27 | 28 | - (void)requestSubjectDataWithCallback:(nonnull JLCompletionCallback)callback { 29 | [self.subjectDataController requestAllSubjects]; 30 | [self.subjectDataController requestUserSubjects]; 31 | // 模拟网络请求延迟 32 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 33 | callback(nil); 34 | }); 35 | } 36 | 37 | - (NSArray *)openSubjects { 38 | return self.subjectDataController.openSubjectsWithCurrentPhase ? self.subjectDataController.openSubjectsWithCurrentPhase : @[]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/DataController/JLSubjectDataController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLSubjectDataController.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLBaseDataController.h" 10 | #import "JLSubject.h" 11 | 12 | @interface JLSubjectDataController : JLBaseDataController 13 | 14 | @property (nonatomic, strong, nullable) NSArray *openSubjectsWithCurrentPhase; 15 | 16 | - (void)requestAllSubjects; 17 | - (void)requestUserSubjects; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/DataController/JLSubjectDataController.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLSubjectDataController.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLSubjectDataController.h" 10 | #import "JLSubject.h" 11 | 12 | @interface JLSubjectDataController () 13 | 14 | @property (nonatomic, copy, nullable) NSArray *allSubjects; 15 | @property (nonatomic, copy, nullable) NSArray *userSubjects; 16 | 17 | @end 18 | 19 | @implementation JLSubjectDataController 20 | 21 | - (void)requestAllSubjects { 22 | // 假数据 23 | JLSubject *math = [[JLSubject alloc] init]; 24 | math.name = @"数学"; 25 | math.id = @1; 26 | 27 | JLSubject *eng = [[JLSubject alloc] init]; 28 | eng.name = @"英语"; 29 | eng.id = @2; 30 | 31 | JLSubject *chem = [[JLSubject alloc] init]; 32 | chem.name = @"化学"; 33 | chem.id = @3; 34 | 35 | JLSubject *phy = [[JLSubject alloc] init]; 36 | phy.name = @"物理"; 37 | phy.id = @4; 38 | 39 | _allSubjects = @[math, eng, chem, phy]; 40 | } 41 | 42 | - (void)requestUserSubjects { 43 | JLSubject *math = [[JLSubject alloc] init]; 44 | math.name = @"数学"; 45 | math.id = @1; 46 | 47 | JLSubject *eng = [[JLSubject alloc] init]; 48 | eng.name = @"英语"; 49 | eng.id = @2; 50 | 51 | JLSubject *chem = [[JLSubject alloc] init]; 52 | chem.name = @"化学"; 53 | chem.id = @3; 54 | 55 | JLSubject *phy = [[JLSubject alloc] init]; 56 | phy.name = @"物理"; 57 | phy.id = @4; 58 | 59 | _userSubjects = @[math, eng, chem, phy]; 60 | } 61 | 62 | - (NSArray *)openSubjectsWithCurrentPhase { 63 | return _allSubjects; 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | LaunchScreen 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 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/Model/JLSubject.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLSubject.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JLSubject : NSObject 12 | 13 | @property (nonatomic, strong, nullable) NSNumber *id; 14 | @property (nonatomic, strong, nullable) NSString *name; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/Model/JLSubject.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLSubject.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLSubject.h" 10 | 11 | @implementation JLSubject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/Supporting Files/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. 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 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeActivityView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeActivityView.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JLHomePracticeSubjectsViewModel.h" 11 | 12 | 13 | @interface JLHomePracticeActivityView : UIView 14 | 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeActivityView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeActivityView.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeActivityView.h" 10 | 11 | @implementation JLHomePracticeActivityView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeBannerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeBannerView.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JLHomePracticeBannerView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeBannerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeBannerView.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeBannerView.h" 10 | 11 | @implementation JLHomePracticeBannerView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeSubjectsCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeSubjectsCollectionViewCell.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JLHomePracticeSubjectsCollectionCellViewModel.h" 11 | 12 | @interface JLHomePracticeSubjectsCollectionViewCell : UICollectionViewCell 13 | 14 | - (void)bindDataWithViewModel:(nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModel; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeSubjectsCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeSubjectsCollectionViewCell.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeSubjectsCollectionViewCell.h" 10 | 11 | @interface JLHomePracticeSubjectsCollectionViewCell () 12 | 13 | @property (nonatomic, strong, nonnull) UILabel *label; 14 | 15 | @end 16 | 17 | @implementation JLHomePracticeSubjectsCollectionViewCell 18 | 19 | - (instancetype) initWithFrame:(CGRect)frame { 20 | self = [super initWithFrame:frame]; 21 | if (self) { 22 | _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 20)]; 23 | _label.center = self.contentView.center; 24 | [self.contentView addSubview:_label]; 25 | } 26 | return self; 27 | } 28 | 29 | - (void)bindDataWithViewModel:(JLHomePracticeSubjectsCollectionCellViewModel *)viewModel { 30 | [_label setText:viewModel.title]; 31 | [_label setTextColor:viewModel.titleColor]; 32 | } 33 | @end 34 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeSubjectsView.h: -------------------------------------------------------------------------------- 1 | // 2 | // APEHomePracticeSubjectsView.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JLHomePracticeSubjectsViewModel.h" 11 | 12 | @interface JLHomePracticeSubjectsView : UIView 13 | 14 | @property (nonatomic, strong, nullable, readonly) JLHomePracticeSubjectsViewModel *viewModel; 15 | 16 | - (void)bindDataWithViewModel:(nonnull JLHomePracticeSubjectsViewModel *)viewModel; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/View/JLHomePracticeSubjectsView.m: -------------------------------------------------------------------------------- 1 | // 2 | // APEHomePracticeSubjectsView.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeSubjectsView.h" 10 | #import "JLHomePracticeSubjectsCollectionViewCell.h" 11 | 12 | @interface JLHomePracticeSubjectsView () 13 | 14 | @property (nonatomic, strong, nullable, readwrite) JLHomePracticeSubjectsViewModel *viewModel; 15 | @property (nonatomic, strong, nonnull) UICollectionView *collectionView; 16 | @end 17 | 18 | @implementation JLHomePracticeSubjectsView 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame { 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; 24 | _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 200, 200) collectionViewLayout:flowLayout]; 25 | _collectionView.delegate = self; 26 | _collectionView.dataSource = self; 27 | [_collectionView registerClass:[JLHomePracticeSubjectsCollectionViewCell class] forCellWithReuseIdentifier:@"Cell"]; 28 | [self addSubview:_collectionView]; 29 | } 30 | return self; 31 | } 32 | 33 | - (void)bindDataWithViewModel:(nonnull JLHomePracticeSubjectsViewModel *)viewModel { 34 | self.viewModel = viewModel; 35 | self.backgroundColor = viewModel.backgroundColor; 36 | [self.collectionView reloadData]; 37 | [self setNeedsUpdateConstraints]; 38 | } 39 | 40 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath: 41 | (NSIndexPath *)indexPath { 42 | JLHomePracticeSubjectsCollectionViewCell *cell = [collectionView 43 | dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 44 | if (0 <= indexPath.row && indexPath.row < self.viewModel.cellViewModels.count) { 45 | JLHomePracticeSubjectsCollectionCellViewModel *vm = 46 | self.viewModel.cellViewModels[indexPath.row]; 47 | [cell bindDataWithViewModel:vm]; 48 | } 49 | return cell; 50 | } 51 | 52 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 53 | return self.viewModel.cellViewModels.count; 54 | } 55 | 56 | @end 57 | 58 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/ViewController/JLHomePracticeViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeViewController.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JLHomePracticeViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/ViewController/JLHomePracticeViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeViewController.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeViewController.h" 10 | #import "JLHomePracticeActivityView.h" 11 | #import "JLHomePracticeBannerView.h" 12 | #import "JLHomePracticeSubjectsView.h" 13 | 14 | #import "JLHomePracticeDataController.h" 15 | 16 | @interface JLHomePracticeViewController () 17 | 18 | @property (nonatomic, strong, nullable) UIScrollView *contentView; 19 | 20 | @property (nonatomic, strong, nullable) JLHomePracticeBannerView *bannerView; 21 | @property (nonatomic, strong, nullable) JLHomePracticeActivityView *activityView; 22 | @property (nonatomic, strong, nullable) JLHomePracticeSubjectsView *subjectsView; 23 | 24 | @property (nonatomic, strong, nullable) JLHomePracticeDataController *dataController; 25 | 26 | @end 27 | 28 | @implementation JLHomePracticeViewController 29 | 30 | #pragma mark - Life cycle 31 | 32 | - (void)viewDidLoad { 33 | _dataController = [[JLHomePracticeDataController alloc] init]; 34 | 35 | [self setupContentView]; 36 | [self fetchSubjectData]; 37 | } 38 | 39 | - (void)setupContentView { 40 | self.contentView = [[UIScrollView alloc] init]; 41 | [self.view addSubview:self.contentView]; 42 | 43 | self.bannerView = [[JLHomePracticeBannerView alloc] init]; 44 | self.activityView = [[JLHomePracticeActivityView alloc] init]; 45 | self.subjectsView = [[JLHomePracticeSubjectsView alloc] init]; 46 | 47 | [self.contentView addSubview:self.bannerView]; 48 | [self.contentView addSubview:self.activityView]; 49 | [self.contentView addSubview:self.subjectsView]; 50 | 51 | 52 | self.contentView.frame = CGRectMake(0, 100, 200, 300); 53 | self.subjectsView.frame = CGRectMake(0, 100, 200, 200); 54 | 55 | } 56 | 57 | #pragma mark - Data 58 | - (void)fetchSubjectData { 59 | [self.dataController requestSubjectDataWithCallback:^(NSError *error) { 60 | if (error == nil) { 61 | [self renderSubjectView]; 62 | } 63 | }]; 64 | } 65 | - (void)renderSubjectView { 66 | JLHomePracticeSubjectsViewModel *viewModel = 67 | [JLHomePracticeSubjectsViewModel viewModelWithSubjects:self.dataController.openSubjects]; 68 | [self.subjectsView bindDataWithViewModel:viewModel]; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/ViewModel/JLHomePracticeSubjectsCollectionCellViewModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeSubjectsCollectionCellViewModel.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JLSubject.h" 11 | 12 | @interface JLHomePracticeSubjectsCollectionCellViewModel : NSObject 13 | 14 | @property (nonatomic, strong, nonnull) UIImage *image; 15 | @property (nonatomic, strong, nonnull) UIImage *highlightedImage; 16 | @property (nonatomic, strong, nonnull) NSString *title; 17 | @property (nonatomic, strong, nonnull) UIColor *titleColor; 18 | @property (nonatomic, strong, nonnull) UIColor *backgroundColor; 19 | 20 | + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelWithSubject:(nonnull JLSubject *)subject; 21 | + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelForMore; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/ViewModel/JLHomePracticeSubjectsCollectionCellViewModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeSubjectsCollectionCellViewModel.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeSubjectsCollectionCellViewModel.h" 10 | 11 | @implementation JLHomePracticeSubjectsCollectionCellViewModel 12 | 13 | + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelWithSubject:(nonnull JLSubject *)subject { 14 | JLHomePracticeSubjectsCollectionCellViewModel *vm = [[JLHomePracticeSubjectsCollectionCellViewModel alloc] init]; 15 | vm.backgroundColor = [UIColor whiteColor]; 16 | vm.title = subject.name; 17 | vm.titleColor = [UIColor greenColor]; 18 | return vm; 19 | } 20 | 21 | + (nonnull JLHomePracticeSubjectsCollectionCellViewModel *)viewModelForMore { 22 | JLHomePracticeSubjectsCollectionCellViewModel *vm = [[JLHomePracticeSubjectsCollectionCellViewModel alloc] init]; 23 | return vm; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/ViewModel/JLHomePracticeSubjectsViewModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeSubjectsViewModel.h 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "JLHomePracticeSubjectsCollectionCellViewModel.h" 11 | #import "JLSubject.h" 12 | 13 | @interface JLHomePracticeSubjectsViewModel : NSObject 14 | 15 | @property (nonatomic, strong, nonnull) NSArray 16 | *cellViewModels; 17 | 18 | @property (nonatomic, strong, nonnull) UIColor *backgroundColor; 19 | 20 | + (nonnull JLHomePracticeSubjectsViewModel *)viewModelWithSubjects:(nonnull NSArray 21 | *)subjects; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /MVVM-DataController-Demo/ViewModel/JLHomePracticeSubjectsViewModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // JLHomePracticeSubjectsViewModel.m 3 | // MVVM-DataController-Demo 4 | // 5 | // Created by skyline on 16/3/15. 6 | // Copyright © 2016年 skyline. All rights reserved. 7 | // 8 | 9 | #import "JLHomePracticeSubjectsViewModel.h" 10 | 11 | @implementation JLHomePracticeSubjectsViewModel 12 | 13 | + (nonnull JLHomePracticeSubjectsViewModel *)viewModelWithSubjects:(nonnull NSArray 14 | *)subjects { 15 | NSMutableArray *arr = [[NSMutableArray alloc] initWithCapacity:subjects.count]; 16 | [subjects enumerateObjectsUsingBlock:^(JLSubject * _Nonnull subject, NSUInteger idx, BOOL * _Nonnull stop) { 17 | [arr addObject:[JLHomePracticeSubjectsCollectionCellViewModel viewModelWithSubject:subject]]; 18 | }]; 19 | JLHomePracticeSubjectsViewModel *vm = [[JLHomePracticeSubjectsViewModel alloc] init]; 20 | vm.cellViewModels = [arr copy]; 21 | vm.backgroundColor = [UIColor whiteColor]; 22 | return vm; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MVVM-DataController-Demo 2 | ======================== 3 | 4 | 一个用于展示猿题库 MVVM without Binding with DataController 架构的 Demo。 5 | 6 | 来源博客:http://gracelancy.com/blog/2016/01/06/ape-ios-arch-design/ 7 | 8 | ![arch](./arch.png) 9 | -------------------------------------------------------------------------------- /arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skyline75489/MVVM-DataController-Demo/b32bfff41caf958c3f76d7b11774d8df946c06a1/arch.png --------------------------------------------------------------------------------