├── .gitignore ├── Headlines.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── mohammadazam.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── Headlines ├── App.swift ├── AppDelegate.swift ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Classes └── DynamicTypes.swift ├── Controllers ├── AddArticleViewController.swift ├── ArticleDetailsViewController.swift ├── ArticleListTableViewController.swift └── ChangePasswordTableViewController.swift ├── Controls └── BindingTextField.swift ├── Extensions └── Extensions.swift ├── Info.plist ├── Models └── Article.swift ├── View Models ├── AddArticleViewModel.swift ├── ArticleDetailViewModel.swift ├── ArticleListViewModel.swift └── ChangePasswordViewModel.swift └── Web Services └── Webservice.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 -------------------------------------------------------------------------------- /Headlines.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 34368ACC1F9A69C3001246D4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368ACB1F9A69C3001246D4 /* AppDelegate.swift */; }; 11 | 34368AD11F9A69C3001246D4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 34368ACF1F9A69C3001246D4 /* Main.storyboard */; }; 12 | 34368AD31F9A69C3001246D4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 34368AD21F9A69C3001246D4 /* Assets.xcassets */; }; 13 | 34368AD61F9A69C3001246D4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 34368AD41F9A69C3001246D4 /* LaunchScreen.storyboard */; }; 14 | 34368ADF1F9A69FD001246D4 /* ArticleListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368ADE1F9A69FD001246D4 /* ArticleListViewModel.swift */; }; 15 | 34368AE21F9A6A3B001246D4 /* ArticleListTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AE11F9A6A3B001246D4 /* ArticleListTableViewController.swift */; }; 16 | 34368AE51F9A6B9A001246D4 /* Webservice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AE41F9A6B9A001246D4 /* Webservice.swift */; }; 17 | 34368AE81F9A6BEE001246D4 /* Article.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AE71F9A6BEE001246D4 /* Article.swift */; }; 18 | 34368AEA1F9A72E2001246D4 /* ArticleDetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AE91F9A72E2001246D4 /* ArticleDetailsViewController.swift */; }; 19 | 34368AEC1F9A741C001246D4 /* ArticleDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AEB1F9A741C001246D4 /* ArticleDetailViewModel.swift */; }; 20 | 34368AEE1F9A828F001246D4 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AED1F9A828F001246D4 /* App.swift */; }; 21 | 34368AF01F9A85B7001246D4 /* AddArticleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AEF1F9A85B7001246D4 /* AddArticleViewController.swift */; }; 22 | 34368AF21F9A8792001246D4 /* AddArticleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AF11F9A8792001246D4 /* AddArticleViewModel.swift */; }; 23 | 34368AF51F9A8C29001246D4 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AF41F9A8C29001246D4 /* Extensions.swift */; }; 24 | 34368AF81F9A9C44001246D4 /* BindingTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AF71F9A9C44001246D4 /* BindingTextField.swift */; }; 25 | 34368AFE1F9AE7AE001246D4 /* DynamicTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34368AFD1F9AE7AE001246D4 /* DynamicTypes.swift */; }; 26 | 349F9FF91F9F67A0009E1885 /* ChangePasswordTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 349F9FF81F9F67A0009E1885 /* ChangePasswordTableViewController.swift */; }; 27 | 349F9FFB1F9F68C7009E1885 /* ChangePasswordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 349F9FFA1F9F68C7009E1885 /* ChangePasswordViewModel.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 34368AC81F9A69C3001246D4 /* Headlines.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Headlines.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 34368ACB1F9A69C3001246D4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | 34368AD01F9A69C3001246D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 34 | 34368AD21F9A69C3001246D4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 35 | 34368AD51F9A69C3001246D4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 36 | 34368AD71F9A69C3001246D4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | 34368ADE1F9A69FD001246D4 /* ArticleListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListViewModel.swift; sourceTree = ""; }; 38 | 34368AE11F9A6A3B001246D4 /* ArticleListTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleListTableViewController.swift; sourceTree = ""; }; 39 | 34368AE41F9A6B9A001246D4 /* Webservice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Webservice.swift; sourceTree = ""; }; 40 | 34368AE71F9A6BEE001246D4 /* Article.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Article.swift; sourceTree = ""; }; 41 | 34368AE91F9A72E2001246D4 /* ArticleDetailsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailsViewController.swift; sourceTree = ""; }; 42 | 34368AEB1F9A741C001246D4 /* ArticleDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailViewModel.swift; sourceTree = ""; }; 43 | 34368AED1F9A828F001246D4 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; 44 | 34368AEF1F9A85B7001246D4 /* AddArticleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddArticleViewController.swift; sourceTree = ""; }; 45 | 34368AF11F9A8792001246D4 /* AddArticleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddArticleViewModel.swift; sourceTree = ""; }; 46 | 34368AF41F9A8C29001246D4 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 47 | 34368AF71F9A9C44001246D4 /* BindingTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindingTextField.swift; sourceTree = ""; }; 48 | 34368AFD1F9AE7AE001246D4 /* DynamicTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicTypes.swift; sourceTree = ""; }; 49 | 349F9FF81F9F67A0009E1885 /* ChangePasswordTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePasswordTableViewController.swift; sourceTree = ""; }; 50 | 349F9FFA1F9F68C7009E1885 /* ChangePasswordViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangePasswordViewModel.swift; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 34368AC51F9A69C3001246D4 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 34368ABF1F9A69C3001246D4 = { 65 | isa = PBXGroup; 66 | children = ( 67 | 34368ACA1F9A69C3001246D4 /* Headlines */, 68 | 34368AC91F9A69C3001246D4 /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | 34368AC91F9A69C3001246D4 /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 34368AC81F9A69C3001246D4 /* Headlines.app */, 76 | ); 77 | name = Products; 78 | sourceTree = ""; 79 | }; 80 | 34368ACA1F9A69C3001246D4 /* Headlines */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | 34368AFC1F9AE7A1001246D4 /* Classes */, 84 | 34368AF91F9AB722001246D4 /* Custom Operators */, 85 | 34368AF61F9A9C36001246D4 /* Controls */, 86 | 34368AF31F9A89AD001246D4 /* Extensions */, 87 | 34368AE61F9A6BE3001246D4 /* Models */, 88 | 34368AE31F9A6B8C001246D4 /* Web Services */, 89 | 34368AE01F9A6A28001246D4 /* Controllers */, 90 | 34368ADD1F9A69EC001246D4 /* View Models */, 91 | 34368ACB1F9A69C3001246D4 /* AppDelegate.swift */, 92 | 34368ACF1F9A69C3001246D4 /* Main.storyboard */, 93 | 34368AD21F9A69C3001246D4 /* Assets.xcassets */, 94 | 34368AD41F9A69C3001246D4 /* LaunchScreen.storyboard */, 95 | 34368AD71F9A69C3001246D4 /* Info.plist */, 96 | 34368AED1F9A828F001246D4 /* App.swift */, 97 | ); 98 | path = Headlines; 99 | sourceTree = ""; 100 | }; 101 | 34368ADD1F9A69EC001246D4 /* View Models */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 34368ADE1F9A69FD001246D4 /* ArticleListViewModel.swift */, 105 | 34368AEB1F9A741C001246D4 /* ArticleDetailViewModel.swift */, 106 | 34368AF11F9A8792001246D4 /* AddArticleViewModel.swift */, 107 | 349F9FFA1F9F68C7009E1885 /* ChangePasswordViewModel.swift */, 108 | ); 109 | path = "View Models"; 110 | sourceTree = ""; 111 | }; 112 | 34368AE01F9A6A28001246D4 /* Controllers */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 34368AE11F9A6A3B001246D4 /* ArticleListTableViewController.swift */, 116 | 34368AE91F9A72E2001246D4 /* ArticleDetailsViewController.swift */, 117 | 34368AEF1F9A85B7001246D4 /* AddArticleViewController.swift */, 118 | 349F9FF81F9F67A0009E1885 /* ChangePasswordTableViewController.swift */, 119 | ); 120 | path = Controllers; 121 | sourceTree = ""; 122 | }; 123 | 34368AE31F9A6B8C001246D4 /* Web Services */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 34368AE41F9A6B9A001246D4 /* Webservice.swift */, 127 | ); 128 | path = "Web Services"; 129 | sourceTree = ""; 130 | }; 131 | 34368AE61F9A6BE3001246D4 /* Models */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 34368AE71F9A6BEE001246D4 /* Article.swift */, 135 | ); 136 | path = Models; 137 | sourceTree = ""; 138 | }; 139 | 34368AF31F9A89AD001246D4 /* Extensions */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 34368AF41F9A8C29001246D4 /* Extensions.swift */, 143 | ); 144 | path = Extensions; 145 | sourceTree = ""; 146 | }; 147 | 34368AF61F9A9C36001246D4 /* Controls */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 34368AF71F9A9C44001246D4 /* BindingTextField.swift */, 151 | ); 152 | path = Controls; 153 | sourceTree = ""; 154 | }; 155 | 34368AF91F9AB722001246D4 /* Custom Operators */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | ); 159 | path = "Custom Operators"; 160 | sourceTree = ""; 161 | }; 162 | 34368AFC1F9AE7A1001246D4 /* Classes */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | 34368AFD1F9AE7AE001246D4 /* DynamicTypes.swift */, 166 | ); 167 | path = Classes; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXGroup section */ 171 | 172 | /* Begin PBXNativeTarget section */ 173 | 34368AC71F9A69C3001246D4 /* Headlines */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = 34368ADA1F9A69C3001246D4 /* Build configuration list for PBXNativeTarget "Headlines" */; 176 | buildPhases = ( 177 | 34368AC41F9A69C3001246D4 /* Sources */, 178 | 34368AC51F9A69C3001246D4 /* Frameworks */, 179 | 34368AC61F9A69C3001246D4 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = Headlines; 186 | productName = Headlines; 187 | productReference = 34368AC81F9A69C3001246D4 /* Headlines.app */; 188 | productType = "com.apple.product-type.application"; 189 | }; 190 | /* End PBXNativeTarget section */ 191 | 192 | /* Begin PBXProject section */ 193 | 34368AC01F9A69C3001246D4 /* Project object */ = { 194 | isa = PBXProject; 195 | attributes = { 196 | LastSwiftUpdateCheck = 0900; 197 | LastUpgradeCheck = 0900; 198 | ORGANIZATIONNAME = "Mohammad Azam"; 199 | TargetAttributes = { 200 | 34368AC71F9A69C3001246D4 = { 201 | CreatedOnToolsVersion = 9.0; 202 | ProvisioningStyle = Automatic; 203 | }; 204 | }; 205 | }; 206 | buildConfigurationList = 34368AC31F9A69C3001246D4 /* Build configuration list for PBXProject "Headlines" */; 207 | compatibilityVersion = "Xcode 8.0"; 208 | developmentRegion = en; 209 | hasScannedForEncodings = 0; 210 | knownRegions = ( 211 | en, 212 | Base, 213 | ); 214 | mainGroup = 34368ABF1F9A69C3001246D4; 215 | productRefGroup = 34368AC91F9A69C3001246D4 /* Products */; 216 | projectDirPath = ""; 217 | projectRoot = ""; 218 | targets = ( 219 | 34368AC71F9A69C3001246D4 /* Headlines */, 220 | ); 221 | }; 222 | /* End PBXProject section */ 223 | 224 | /* Begin PBXResourcesBuildPhase section */ 225 | 34368AC61F9A69C3001246D4 /* Resources */ = { 226 | isa = PBXResourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | 34368AD61F9A69C3001246D4 /* LaunchScreen.storyboard in Resources */, 230 | 34368AD31F9A69C3001246D4 /* Assets.xcassets in Resources */, 231 | 34368AD11F9A69C3001246D4 /* Main.storyboard in Resources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | /* End PBXResourcesBuildPhase section */ 236 | 237 | /* Begin PBXSourcesBuildPhase section */ 238 | 34368AC41F9A69C3001246D4 /* Sources */ = { 239 | isa = PBXSourcesBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | 34368ADF1F9A69FD001246D4 /* ArticleListViewModel.swift in Sources */, 243 | 34368AE21F9A6A3B001246D4 /* ArticleListTableViewController.swift in Sources */, 244 | 34368AF01F9A85B7001246D4 /* AddArticleViewController.swift in Sources */, 245 | 34368AEA1F9A72E2001246D4 /* ArticleDetailsViewController.swift in Sources */, 246 | 34368AE51F9A6B9A001246D4 /* Webservice.swift in Sources */, 247 | 34368AF21F9A8792001246D4 /* AddArticleViewModel.swift in Sources */, 248 | 349F9FF91F9F67A0009E1885 /* ChangePasswordTableViewController.swift in Sources */, 249 | 34368AEC1F9A741C001246D4 /* ArticleDetailViewModel.swift in Sources */, 250 | 34368AEE1F9A828F001246D4 /* App.swift in Sources */, 251 | 34368AF81F9A9C44001246D4 /* BindingTextField.swift in Sources */, 252 | 349F9FFB1F9F68C7009E1885 /* ChangePasswordViewModel.swift in Sources */, 253 | 34368ACC1F9A69C3001246D4 /* AppDelegate.swift in Sources */, 254 | 34368AF51F9A8C29001246D4 /* Extensions.swift in Sources */, 255 | 34368AE81F9A6BEE001246D4 /* Article.swift in Sources */, 256 | 34368AFE1F9AE7AE001246D4 /* DynamicTypes.swift in Sources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | /* End PBXSourcesBuildPhase section */ 261 | 262 | /* Begin PBXVariantGroup section */ 263 | 34368ACF1F9A69C3001246D4 /* Main.storyboard */ = { 264 | isa = PBXVariantGroup; 265 | children = ( 266 | 34368AD01F9A69C3001246D4 /* Base */, 267 | ); 268 | name = Main.storyboard; 269 | sourceTree = ""; 270 | }; 271 | 34368AD41F9A69C3001246D4 /* LaunchScreen.storyboard */ = { 272 | isa = PBXVariantGroup; 273 | children = ( 274 | 34368AD51F9A69C3001246D4 /* Base */, 275 | ); 276 | name = LaunchScreen.storyboard; 277 | sourceTree = ""; 278 | }; 279 | /* End PBXVariantGroup section */ 280 | 281 | /* Begin XCBuildConfiguration section */ 282 | 34368AD81F9A69C3001246D4 /* Debug */ = { 283 | isa = XCBuildConfiguration; 284 | buildSettings = { 285 | ALWAYS_SEARCH_USER_PATHS = NO; 286 | CLANG_ANALYZER_NONNULL = YES; 287 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 289 | CLANG_CXX_LIBRARY = "libc++"; 290 | CLANG_ENABLE_MODULES = YES; 291 | CLANG_ENABLE_OBJC_ARC = YES; 292 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 293 | CLANG_WARN_BOOL_CONVERSION = YES; 294 | CLANG_WARN_COMMA = YES; 295 | CLANG_WARN_CONSTANT_CONVERSION = YES; 296 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 297 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 298 | CLANG_WARN_EMPTY_BODY = YES; 299 | CLANG_WARN_ENUM_CONVERSION = YES; 300 | CLANG_WARN_INFINITE_RECURSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 303 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 304 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 305 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 306 | CLANG_WARN_STRICT_PROTOTYPES = YES; 307 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 308 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 309 | CLANG_WARN_UNREACHABLE_CODE = YES; 310 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 311 | CODE_SIGN_IDENTITY = "iPhone Developer"; 312 | COPY_PHASE_STRIP = NO; 313 | DEBUG_INFORMATION_FORMAT = dwarf; 314 | ENABLE_STRICT_OBJC_MSGSEND = YES; 315 | ENABLE_TESTABILITY = YES; 316 | GCC_C_LANGUAGE_STANDARD = gnu11; 317 | GCC_DYNAMIC_NO_PIC = NO; 318 | GCC_NO_COMMON_BLOCKS = YES; 319 | GCC_OPTIMIZATION_LEVEL = 0; 320 | GCC_PREPROCESSOR_DEFINITIONS = ( 321 | "DEBUG=1", 322 | "$(inherited)", 323 | ); 324 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 325 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 326 | GCC_WARN_UNDECLARED_SELECTOR = YES; 327 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 328 | GCC_WARN_UNUSED_FUNCTION = YES; 329 | GCC_WARN_UNUSED_VARIABLE = YES; 330 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 331 | MTL_ENABLE_DEBUG_INFO = YES; 332 | ONLY_ACTIVE_ARCH = YES; 333 | SDKROOT = iphoneos; 334 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 335 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 336 | }; 337 | name = Debug; 338 | }; 339 | 34368AD91F9A69C3001246D4 /* Release */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ALWAYS_SEARCH_USER_PATHS = NO; 343 | CLANG_ANALYZER_NONNULL = YES; 344 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 345 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 346 | CLANG_CXX_LIBRARY = "libc++"; 347 | CLANG_ENABLE_MODULES = YES; 348 | CLANG_ENABLE_OBJC_ARC = YES; 349 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 350 | CLANG_WARN_BOOL_CONVERSION = YES; 351 | CLANG_WARN_COMMA = YES; 352 | CLANG_WARN_CONSTANT_CONVERSION = YES; 353 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 354 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 355 | CLANG_WARN_EMPTY_BODY = YES; 356 | CLANG_WARN_ENUM_CONVERSION = YES; 357 | CLANG_WARN_INFINITE_RECURSION = YES; 358 | CLANG_WARN_INT_CONVERSION = YES; 359 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 360 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 362 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 363 | CLANG_WARN_STRICT_PROTOTYPES = YES; 364 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 365 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 366 | CLANG_WARN_UNREACHABLE_CODE = YES; 367 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 368 | CODE_SIGN_IDENTITY = "iPhone Developer"; 369 | COPY_PHASE_STRIP = NO; 370 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 371 | ENABLE_NS_ASSERTIONS = NO; 372 | ENABLE_STRICT_OBJC_MSGSEND = YES; 373 | GCC_C_LANGUAGE_STANDARD = gnu11; 374 | GCC_NO_COMMON_BLOCKS = YES; 375 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 376 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 377 | GCC_WARN_UNDECLARED_SELECTOR = YES; 378 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 379 | GCC_WARN_UNUSED_FUNCTION = YES; 380 | GCC_WARN_UNUSED_VARIABLE = YES; 381 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 382 | MTL_ENABLE_DEBUG_INFO = NO; 383 | SDKROOT = iphoneos; 384 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 385 | VALIDATE_PRODUCT = YES; 386 | }; 387 | name = Release; 388 | }; 389 | 34368ADB1F9A69C3001246D4 /* Debug */ = { 390 | isa = XCBuildConfiguration; 391 | buildSettings = { 392 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 393 | CODE_SIGN_STYLE = Automatic; 394 | DEVELOPMENT_TEAM = B2Q8EGNCQA; 395 | INFOPLIST_FILE = Headlines/Info.plist; 396 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 397 | PRODUCT_BUNDLE_IDENTIFIER = com.azamsharp.Headlines; 398 | PRODUCT_NAME = "$(TARGET_NAME)"; 399 | SWIFT_VERSION = 4.0; 400 | TARGETED_DEVICE_FAMILY = "1,2"; 401 | }; 402 | name = Debug; 403 | }; 404 | 34368ADC1F9A69C3001246D4 /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 408 | CODE_SIGN_STYLE = Automatic; 409 | DEVELOPMENT_TEAM = B2Q8EGNCQA; 410 | INFOPLIST_FILE = Headlines/Info.plist; 411 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 412 | PRODUCT_BUNDLE_IDENTIFIER = com.azamsharp.Headlines; 413 | PRODUCT_NAME = "$(TARGET_NAME)"; 414 | SWIFT_VERSION = 4.0; 415 | TARGETED_DEVICE_FAMILY = "1,2"; 416 | }; 417 | name = Release; 418 | }; 419 | /* End XCBuildConfiguration section */ 420 | 421 | /* Begin XCConfigurationList section */ 422 | 34368AC31F9A69C3001246D4 /* Build configuration list for PBXProject "Headlines" */ = { 423 | isa = XCConfigurationList; 424 | buildConfigurations = ( 425 | 34368AD81F9A69C3001246D4 /* Debug */, 426 | 34368AD91F9A69C3001246D4 /* Release */, 427 | ); 428 | defaultConfigurationIsVisible = 0; 429 | defaultConfigurationName = Release; 430 | }; 431 | 34368ADA1F9A69C3001246D4 /* Build configuration list for PBXNativeTarget "Headlines" */ = { 432 | isa = XCConfigurationList; 433 | buildConfigurations = ( 434 | 34368ADB1F9A69C3001246D4 /* Debug */, 435 | 34368ADC1F9A69C3001246D4 /* Release */, 436 | ); 437 | defaultConfigurationIsVisible = 0; 438 | defaultConfigurationName = Release; 439 | }; 440 | /* End XCConfigurationList section */ 441 | }; 442 | rootObject = 34368AC01F9A69C3001246D4 /* Project object */; 443 | } 444 | -------------------------------------------------------------------------------- /Headlines.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Headlines.xcodeproj/xcuserdata/mohammadazam.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Headlines.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Headlines/App.swift: -------------------------------------------------------------------------------- 1 | // 2 | // App.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class App { 13 | 14 | let storyboard = UIStoryboard(name: "Main", bundle: nil) 15 | let navigationController :UINavigationController 16 | 17 | init(window :UIWindow) { 18 | 19 | navigationController = window.rootViewController as! UINavigationController 20 | 21 | guard let articleListTVC = navigationController.viewControllers.first as? ArticleListTableViewController else { 22 | fatalError("ArticleListTableViewController does not exist") 23 | } 24 | 25 | articleListTVC.didSelect = showArticleDetails 26 | articleListTVC.addArticleTapped = showAddArticle 27 | 28 | } 29 | 30 | private func showAddArticle() { 31 | 32 | let addArticleNC = storyboard.instantiateViewController(withIdentifier: "AddArticleNavigationController") as! UINavigationController 33 | 34 | navigationController.present(addArticleNC, animated: true, completion: nil) 35 | } 36 | 37 | private func showArticleDetails(articleViewModel :ArticleViewModel) { 38 | 39 | let articleDetailVC = storyboard.instantiateViewController(withIdentifier: "ArticleDetailsViewController") as! ArticleDetailsViewController 40 | 41 | articleDetailVC.articleDetailViewModel = ArticleDetailViewModel(articleViewModel: articleViewModel) 42 | 43 | navigationController.pushViewController(articleDetailVC, animated: true) 44 | } 45 | 46 | } 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Headlines/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | var app :App? 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | 19 | if let window = window { 20 | // app = App(window: window) 21 | } 22 | 23 | return true 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /Headlines/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /Headlines/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 | -------------------------------------------------------------------------------- /Headlines/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /Headlines/Classes/DynamicTypes.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DynamicTypes.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Dynamic { 12 | 13 | var bind :(T) -> () = { _ in } 14 | 15 | var value :T? { 16 | didSet { 17 | bind(value!) 18 | } 19 | } 20 | 21 | init(_ v :T) { 22 | value = v 23 | } 24 | 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /Headlines/Controllers/AddArticleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddArticleViewController.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class AddArticleViewController : UIViewController { 13 | 14 | // For this example assume they are UITextField 15 | @IBOutlet weak var titleTextField :BindingTextField! { 16 | didSet { 17 | titleTextField.bind { self.viewModel.title.value = $0 } 18 | } 19 | } 20 | @IBOutlet weak var descriptionTextField :BindingTextField! { 21 | didSet { 22 | descriptionTextField.bind { self.viewModel.description.value = $0 } 23 | } 24 | } 25 | 26 | var viewModel :AddArticleViewModel! { 27 | 28 | didSet { 29 | viewModel.title.bind = { [unowned self] in self.titleTextField.text = $0 } 30 | viewModel.description.bind = { [unowned self] in self.descriptionTextField.text = $0 } 31 | } 32 | } 33 | 34 | @IBAction func AddArticleButtonPressed(_ sender: Any) { 35 | 36 | self.viewModel.title.value = "hello world" 37 | self.viewModel.description.value = "description" 38 | } 39 | 40 | override func viewDidLoad() { 41 | 42 | super.viewDidLoad() 43 | self.viewModel = AddArticleViewModel() 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Headlines/Controllers/ArticleDetailsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArticleDetailsViewController.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class ArticleDetailsViewController : UIViewController { 13 | 14 | var articleDetailViewModel :ArticleDetailViewModel! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | self.title = self.articleDetailViewModel.articleViewModel.title 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Headlines/Controllers/ArticleListTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArticleListTableViewController.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class ArticleListTableViewController : UITableViewController { 13 | 14 | private var viewModel :ArticleListViewModel = ArticleListViewModel() { 15 | 16 | didSet { 17 | self.tableView.reloadData() 18 | } 19 | } 20 | 21 | 22 | var didSelect: (ArticleViewModel) -> () = { _ in } 23 | var addArticleTapped: () -> () = {} 24 | 25 | override func viewDidLoad() { 26 | super.viewDidLoad() 27 | 28 | self.title = self.viewModel.title 29 | 30 | loadArticles() 31 | } 32 | 33 | private func loadArticles() { 34 | 35 | // this url should be part of the URL builder scheme and not right inside the 36 | // view controller but right now we are focused on MVVM 37 | let url = URL(string: "https://newsapi.org/v1/articles?source=the-next-web&sortBy=latest&apiKey=0cf790498275413a9247f8b94b3843fd")! 38 | 39 | // this web service should use generic types. Again this is not part of the implementation 40 | // as we are focusing on MVVM model 41 | Webservice().getArticles(url: url) { articles in 42 | print(articles) 43 | 44 | let articles = articles.map { article in 45 | return ArticleViewModel(article :article) 46 | } 47 | 48 | self.viewModel = ArticleListViewModel(articles :articles) 49 | 50 | } 51 | } 52 | 53 | @IBAction func addArticleButtonTapped(_ sender: Any) { 54 | 55 | addArticleTapped() 56 | } 57 | 58 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 59 | 60 | let articleViewModel = self.viewModel.articles[indexPath.row] 61 | didSelect(articleViewModel) 62 | } 63 | 64 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 65 | return self.viewModel.articles.count 66 | } 67 | 68 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 69 | 70 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) 71 | let articleViewModel = self.viewModel.articles[indexPath.row] 72 | 73 | cell.textLabel?.text = articleViewModel.title 74 | return cell 75 | } 76 | } 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Headlines/Controllers/ChangePasswordTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChangePasswordTableViewController.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/24/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class ChangePasswordTableViewController : UITableViewController { 13 | 14 | private var viewModel :ChangePasswordViewModel = ChangePasswordViewModel() 15 | 16 | @IBOutlet weak var newPasswordTextField :BindingTextField! { 17 | didSet { 18 | self.newPasswordTextField.bind { self.viewModel.newPassword.value = $0 } 19 | } 20 | } 21 | @IBOutlet weak var confirmPasswordTextField :BindingTextField! { 22 | didSet { 23 | self.confirmPasswordTextField.bind { self.viewModel.confirmPassword.value = $0 } 24 | } 25 | } 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | } 30 | 31 | @IBAction func save() { 32 | 33 | if self.viewModel.isValid { 34 | // update the password 35 | print("update the user's password") 36 | } else { 37 | // show errors 38 | print(self.viewModel.brokenRules) 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Headlines/Controls/BindingTextField.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BindingTextBox.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class BindingTextField : UITextField { 13 | 14 | var textChanged :(String) -> () = { _ in } 15 | 16 | func bind(callback :@escaping (String) -> ()) { 17 | 18 | self.textChanged = callback 19 | self.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged) 20 | } 21 | 22 | @objc func textFieldDidChange(_ textField :UITextField) { 23 | 24 | self.textChanged(textField.text!) 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Headlines/Extensions/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | -------------------------------------------------------------------------------- /Headlines/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Headlines/Models/Article.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Article.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Article { 12 | 13 | var title :String 14 | var description :String 15 | 16 | init(title :String, description: String) { 17 | self.title = title 18 | self.description = description 19 | } 20 | 21 | init?(dictionary :JSONDictionary) { 22 | 23 | guard let title = dictionary["title"] as? String, 24 | let description = dictionary["description"] as? String else { 25 | return nil 26 | } 27 | self.title = title 28 | self.description = description 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Headlines/View Models/AddArticleViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddArticleViewModel.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct AddArticleViewModel { 12 | 13 | var title :Dynamic = Dynamic("") 14 | var description :Dynamic = Dynamic("") 15 | } 16 | 17 | extension AddArticleViewModel { 18 | 19 | init(article :Article) { 20 | self.title = Dynamic(article.title) 21 | self.description = Dynamic(article.description) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Headlines/View Models/ArticleDetailViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArticleDetailViewModel.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct ArticleDetailViewModel { 12 | 13 | var articleViewModel :ArticleViewModel 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Headlines/View Models/ArticleListViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ArticleListViewModel.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | struct ArticleListViewModel { 13 | 14 | var title :String? = "Articles" 15 | var articles :[ArticleViewModel] = [ArticleViewModel]() 16 | } 17 | 18 | extension ArticleListViewModel { 19 | 20 | init(articles :[ArticleViewModel]) { 21 | self.articles = articles 22 | } 23 | 24 | } 25 | 26 | struct ArticleViewModel { 27 | 28 | var title :String 29 | var description :String 30 | } 31 | 32 | extension ArticleViewModel { 33 | 34 | init(article :Article) { 35 | self.title = article.title 36 | self.description = article.description 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Headlines/View Models/ChangePasswordViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChangePasswordViewModel.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/24/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | 13 | struct BrokenRule { 14 | 15 | var propertyName :String 16 | var message :String 17 | } 18 | 19 | protocol ViewModel { 20 | 21 | var brokenRules :[BrokenRule] { get set} 22 | var isValid :Bool { mutating get } 23 | } 24 | 25 | struct ChangePasswordViewModel : ViewModel { 26 | 27 | var brokenRules: [BrokenRule] = [BrokenRule]() 28 | 29 | var newPassword = Dynamic("") 30 | var confirmPassword = Dynamic("") 31 | 32 | var isValid :Bool { 33 | mutating get { 34 | self.brokenRules = [BrokenRule]() 35 | self.validate() 36 | return self.brokenRules.count == 0 ? true : false 37 | } 38 | } 39 | } 40 | 41 | extension ChangePasswordViewModel { 42 | 43 | mutating private func validate() { 44 | 45 | if newPassword.value != confirmPassword.value { 46 | self.brokenRules.append(BrokenRule(propertyName: "confirmPassword", message: "Passwords are not matching")) 47 | } 48 | 49 | if (newPassword.value?.count)! < 8 { 50 | self.brokenRules.append(BrokenRule(propertyName: "newPassword", message: "Password should be at least 8 characters long")) 51 | } 52 | 53 | } 54 | 55 | } 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Headlines/Web Services/Webservice.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Webservice.swift 3 | // Headlines 4 | // 5 | // Created by Mohammad Azam on 10/20/17. 6 | // Copyright © 2017 Mohammad Azam. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | typealias JSONDictionary = [String:Any] 12 | 13 | class Webservice { 14 | 15 | func getArticles(url :URL, callback :@escaping ([Article]) -> ()) { 16 | 17 | var articles = [Article]() 18 | 19 | URLSession.shared.dataTask(with: url) { data, response, error in 20 | 21 | if let data = data { 22 | 23 | let json = try! JSONSerialization.jsonObject(with: data, options: []) 24 | let dictionary = json as! JSONDictionary 25 | 26 | let articleDictionaries = dictionary["articles"] as! [JSONDictionary] 27 | 28 | articles = articleDictionaries.flatMap { dictionary in 29 | return Article(dictionary :dictionary) 30 | } 31 | } 32 | 33 | DispatchQueue.main.async { 34 | callback(articles) 35 | } 36 | 37 | }.resume() 38 | 39 | } 40 | 41 | } 42 | --------------------------------------------------------------------------------