diff --git a/Practical Example/.DS_Store b/Practical Example/.DS_Store new file mode 100644 index 0000000..3cb3f13 Binary files /dev/null and b/Practical Example/.DS_Store differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/.DS_Store b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/.DS_Store new file mode 100644 index 0000000..bafc90d Binary files /dev/null and b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/.DS_Store differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.pbxproj b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.pbxproj new file mode 100644 index 0000000..20c2eab --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.pbxproj @@ -0,0 +1,589 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + AC9A457A28D125B10032DD02 /* Resource.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A457928D125B10032DD02 /* Resource.swift */; }; + AC9A457D28D129980032DD02 /* Endpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A457C28D129980032DD02 /* Endpoint.swift */; }; + AC9A457F28D12C350032DD02 /* RayWenderlich.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A457E28D12C350032DD02 /* RayWenderlich.swift */; }; + AC9A458228D130660032DD02 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A458128D130660032DD02 /* NetworkManager.swift */; }; + AC9A458528D13B500032DD02 /* Logging.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A458428D13B500032DD02 /* Logging.swift */; }; + AC9A458728D140630032DD02 /* ReachabilityMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A458628D140630032DD02 /* ReachabilityMonitor.swift */; }; + AC9A458A28D14A180032DD02 /* ResourceListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A458928D14A180032DD02 /* ResourceListViewModel.swift */; }; + AC9A458C28D192790032DD02 /* ResourceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A458B28D192790032DD02 /* ResourceView.swift */; }; + AC9A458E28D193350032DD02 /* ResourceView.xib in Resources */ = {isa = PBXBuildFile; fileRef = AC9A458D28D193350032DD02 /* ResourceView.xib */; }; + AC9A459228D3BBAB0032DD02 /* UIImageExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC9A459128D3BBAB0032DD02 /* UIImageExtensions.swift */; }; + ACBDD07728D1201B0075927E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACBDD07628D1201B0075927E /* AppDelegate.swift */; }; + ACBDD07928D1201B0075927E /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACBDD07828D1201B0075927E /* SceneDelegate.swift */; }; + ACBDD07B28D1201B0075927E /* ResourceListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACBDD07A28D1201B0075927E /* ResourceListViewController.swift */; }; + ACBDD08128D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = ACBDD07F28D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodeld */; }; + ACBDD08328D1201C0075927E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ACBDD08228D1201C0075927E /* Assets.xcassets */; }; + ACBDD08628D1201C0075927E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ACBDD08428D1201C0075927E /* LaunchScreen.storyboard */; }; + ACBDD09128D1201C0075927E /* Raywenderlich_Interview_take_homeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACBDD09028D1201C0075927E /* Raywenderlich_Interview_take_homeTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + ACBDD08D28D1201C0075927E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = ACBDD06B28D1201A0075927E /* Project object */; + proxyType = 1; + remoteGlobalIDString = ACBDD07228D1201B0075927E; + remoteInfo = "Raywenderlich Interview take home"; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + AC9A457928D125B10032DD02 /* Resource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Resource.swift; sourceTree = ""; }; + AC9A457C28D129980032DD02 /* Endpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Endpoint.swift; sourceTree = ""; }; + AC9A457E28D12C350032DD02 /* RayWenderlich.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RayWenderlich.swift; sourceTree = ""; }; + AC9A458128D130660032DD02 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = ""; }; + AC9A458428D13B500032DD02 /* Logging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logging.swift; sourceTree = ""; }; + AC9A458628D140630032DD02 /* ReachabilityMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReachabilityMonitor.swift; sourceTree = ""; }; + AC9A458928D14A180032DD02 /* ResourceListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceListViewModel.swift; sourceTree = ""; }; + AC9A458B28D192790032DD02 /* ResourceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceView.swift; sourceTree = ""; }; + AC9A458D28D193350032DD02 /* ResourceView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ResourceView.xib; sourceTree = ""; }; + AC9A459128D3BBAB0032DD02 /* UIImageExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageExtensions.swift; sourceTree = ""; }; + ACBDD07328D1201B0075927E /* Raywenderlich Interview take home.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Raywenderlich Interview take home.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + ACBDD07628D1201B0075927E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + ACBDD07828D1201B0075927E /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + ACBDD07A28D1201B0075927E /* ResourceListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourceListViewController.swift; sourceTree = ""; }; + ACBDD08028D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Raywenderlich_Interview_take_home.xcdatamodel; sourceTree = ""; }; + ACBDD08228D1201C0075927E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + ACBDD08528D1201C0075927E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + ACBDD08728D1201C0075927E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ACBDD08C28D1201C0075927E /* Raywenderlich Interview take homeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Raywenderlich Interview take homeTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + ACBDD09028D1201C0075927E /* Raywenderlich_Interview_take_homeTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Raywenderlich_Interview_take_homeTests.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + ACBDD07028D1201B0075927E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ACBDD08928D1201C0075927E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + AC9A457828D1258E0032DD02 /* Models */ = { + isa = PBXGroup; + children = ( + AC9A457928D125B10032DD02 /* Resource.swift */, + ); + path = Models; + sourceTree = ""; + }; + AC9A457B28D129880032DD02 /* Networking */ = { + isa = PBXGroup; + children = ( + AC9A458028D12DB70032DD02 /* Endpoints */, + AC9A457C28D129980032DD02 /* Endpoint.swift */, + AC9A458128D130660032DD02 /* NetworkManager.swift */, + AC9A458628D140630032DD02 /* ReachabilityMonitor.swift */, + ); + path = Networking; + sourceTree = ""; + }; + AC9A458028D12DB70032DD02 /* Endpoints */ = { + isa = PBXGroup; + children = ( + AC9A457E28D12C350032DD02 /* RayWenderlich.swift */, + ); + path = Endpoints; + sourceTree = ""; + }; + AC9A458328D13B480032DD02 /* Logging */ = { + isa = PBXGroup; + children = ( + AC9A458428D13B500032DD02 /* Logging.swift */, + ); + path = Logging; + sourceTree = ""; + }; + AC9A458828D1489B0032DD02 /* ResourceList */ = { + isa = PBXGroup; + children = ( + ACBDD07A28D1201B0075927E /* ResourceListViewController.swift */, + AC9A458928D14A180032DD02 /* ResourceListViewModel.swift */, + AC9A458B28D192790032DD02 /* ResourceView.swift */, + AC9A458D28D193350032DD02 /* ResourceView.xib */, + ); + path = ResourceList; + sourceTree = ""; + }; + AC9A458F28D3BB980032DD02 /* Core */ = { + isa = PBXGroup; + children = ( + AC9A459028D3BB9F0032DD02 /* Extensions */, + ); + path = Core; + sourceTree = ""; + }; + AC9A459028D3BB9F0032DD02 /* Extensions */ = { + isa = PBXGroup; + children = ( + AC9A459128D3BBAB0032DD02 /* UIImageExtensions.swift */, + ); + path = Extensions; + sourceTree = ""; + }; + ACBDD06A28D1201A0075927E = { + isa = PBXGroup; + children = ( + ACBDD07528D1201B0075927E /* Raywenderlich Interview take home */, + ACBDD08F28D1201C0075927E /* Raywenderlich Interview take homeTests */, + ACBDD07428D1201B0075927E /* Products */, + ); + sourceTree = ""; + }; + ACBDD07428D1201B0075927E /* Products */ = { + isa = PBXGroup; + children = ( + ACBDD07328D1201B0075927E /* Raywenderlich Interview take home.app */, + ACBDD08C28D1201C0075927E /* Raywenderlich Interview take homeTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + ACBDD07528D1201B0075927E /* Raywenderlich Interview take home */ = { + isa = PBXGroup; + children = ( + AC9A458F28D3BB980032DD02 /* Core */, + AC9A458828D1489B0032DD02 /* ResourceList */, + AC9A458328D13B480032DD02 /* Logging */, + AC9A457B28D129880032DD02 /* Networking */, + AC9A457828D1258E0032DD02 /* Models */, + ACBDD07628D1201B0075927E /* AppDelegate.swift */, + ACBDD07828D1201B0075927E /* SceneDelegate.swift */, + ACBDD08228D1201C0075927E /* Assets.xcassets */, + ACBDD08428D1201C0075927E /* LaunchScreen.storyboard */, + ACBDD08728D1201C0075927E /* Info.plist */, + ACBDD07F28D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodeld */, + ); + path = "Raywenderlich Interview take home"; + sourceTree = ""; + }; + ACBDD08F28D1201C0075927E /* Raywenderlich Interview take homeTests */ = { + isa = PBXGroup; + children = ( + ACBDD09028D1201C0075927E /* Raywenderlich_Interview_take_homeTests.swift */, + ); + path = "Raywenderlich Interview take homeTests"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + ACBDD07228D1201B0075927E /* Raywenderlich Interview take home */ = { + isa = PBXNativeTarget; + buildConfigurationList = ACBDD0A028D1201C0075927E /* Build configuration list for PBXNativeTarget "Raywenderlich Interview take home" */; + buildPhases = ( + ACBDD06F28D1201B0075927E /* Sources */, + ACBDD07028D1201B0075927E /* Frameworks */, + ACBDD07128D1201B0075927E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Raywenderlich Interview take home"; + productName = "Raywenderlich Interview take home"; + productReference = ACBDD07328D1201B0075927E /* Raywenderlich Interview take home.app */; + productType = "com.apple.product-type.application"; + }; + ACBDD08B28D1201C0075927E /* Raywenderlich Interview take homeTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = ACBDD0A328D1201C0075927E /* Build configuration list for PBXNativeTarget "Raywenderlich Interview take homeTests" */; + buildPhases = ( + ACBDD08828D1201C0075927E /* Sources */, + ACBDD08928D1201C0075927E /* Frameworks */, + ACBDD08A28D1201C0075927E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ACBDD08E28D1201C0075927E /* PBXTargetDependency */, + ); + name = "Raywenderlich Interview take homeTests"; + productName = "Raywenderlich Interview take homeTests"; + productReference = ACBDD08C28D1201C0075927E /* Raywenderlich Interview take homeTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + ACBDD06B28D1201A0075927E /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1400; + LastUpgradeCheck = 1400; + TargetAttributes = { + ACBDD07228D1201B0075927E = { + CreatedOnToolsVersion = 14.0; + }; + ACBDD08B28D1201C0075927E = { + CreatedOnToolsVersion = 14.0; + TestTargetID = ACBDD07228D1201B0075927E; + }; + }; + }; + buildConfigurationList = ACBDD06E28D1201A0075927E /* Build configuration list for PBXProject "Raywenderlich Interview take home" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = ACBDD06A28D1201A0075927E; + productRefGroup = ACBDD07428D1201B0075927E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + ACBDD07228D1201B0075927E /* Raywenderlich Interview take home */, + ACBDD08B28D1201C0075927E /* Raywenderlich Interview take homeTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + ACBDD07128D1201B0075927E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AC9A458E28D193350032DD02 /* ResourceView.xib in Resources */, + ACBDD08628D1201C0075927E /* LaunchScreen.storyboard in Resources */, + ACBDD08328D1201C0075927E /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ACBDD08A28D1201C0075927E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + ACBDD06F28D1201B0075927E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AC9A457F28D12C350032DD02 /* RayWenderlich.swift in Sources */, + ACBDD07B28D1201B0075927E /* ResourceListViewController.swift in Sources */, + ACBDD07728D1201B0075927E /* AppDelegate.swift in Sources */, + AC9A458A28D14A180032DD02 /* ResourceListViewModel.swift in Sources */, + ACBDD07928D1201B0075927E /* SceneDelegate.swift in Sources */, + AC9A459228D3BBAB0032DD02 /* UIImageExtensions.swift in Sources */, + AC9A458228D130660032DD02 /* NetworkManager.swift in Sources */, + ACBDD08128D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodeld in Sources */, + AC9A457D28D129980032DD02 /* Endpoint.swift in Sources */, + AC9A458C28D192790032DD02 /* ResourceView.swift in Sources */, + AC9A458528D13B500032DD02 /* Logging.swift in Sources */, + AC9A457A28D125B10032DD02 /* Resource.swift in Sources */, + AC9A458728D140630032DD02 /* ReachabilityMonitor.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ACBDD08828D1201C0075927E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ACBDD09128D1201C0075927E /* Raywenderlich_Interview_take_homeTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + ACBDD08E28D1201C0075927E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = ACBDD07228D1201B0075927E /* Raywenderlich Interview take home */; + targetProxy = ACBDD08D28D1201C0075927E /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + ACBDD08428D1201C0075927E /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + ACBDD08528D1201C0075927E /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + ACBDD09E28D1201C0075927E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + ACBDD09F28D1201C0075927E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + ACBDD0A128D1201C0075927E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 486TSQPHB9; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "Raywenderlich Interview take home/Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = ""; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.yazanhalawa.Raywenderlich-Interview-take-home"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + ACBDD0A228D1201C0075927E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 486TSQPHB9; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = "Raywenderlich Interview take home/Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = ""; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.yazanhalawa.Raywenderlich-Interview-take-home"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + ACBDD0A428D1201C0075927E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 486TSQPHB9; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.yazanhalawa.Raywenderlich-Interview-take-homeTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Raywenderlich Interview take home.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Raywenderlich Interview take home"; + }; + name = Debug; + }; + ACBDD0A528D1201C0075927E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 486TSQPHB9; + GENERATE_INFOPLIST_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "com.yazanhalawa.Raywenderlich-Interview-take-homeTests"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Raywenderlich Interview take home.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Raywenderlich Interview take home"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + ACBDD06E28D1201A0075927E /* Build configuration list for PBXProject "Raywenderlich Interview take home" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ACBDD09E28D1201C0075927E /* Debug */, + ACBDD09F28D1201C0075927E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ACBDD0A028D1201C0075927E /* Build configuration list for PBXNativeTarget "Raywenderlich Interview take home" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ACBDD0A128D1201C0075927E /* Debug */, + ACBDD0A228D1201C0075927E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + ACBDD0A328D1201C0075927E /* Build configuration list for PBXNativeTarget "Raywenderlich Interview take homeTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + ACBDD0A428D1201C0075927E /* Debug */, + ACBDD0A528D1201C0075927E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + ACBDD07F28D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + ACBDD08028D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodel */, + ); + currentVersion = ACBDD08028D1201B0075927E /* Raywenderlich_Interview_take_home.xcdatamodel */; + path = Raywenderlich_Interview_take_home.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = ACBDD06B28D1201A0075927E /* Project object */; +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcuserdata/Yazan.xcuserdatad/UserInterfaceState.xcuserstate b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcuserdata/Yazan.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..aeef6b6 Binary files /dev/null and b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcuserdata/Yazan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcuserdata/Yazan.xcuserdatad/xcdebugger/Expressions.xcexplist b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcuserdata/Yazan.xcuserdatad/xcdebugger/Expressions.xcexplist new file mode 100644 index 0000000..c962322 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/project.xcworkspace/xcuserdata/Yazan.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcshareddata/xcschemes/Raywenderlich Interview take home.xcscheme b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcshareddata/xcschemes/Raywenderlich Interview take home.xcscheme new file mode 100644 index 0000000..6c8be35 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcshareddata/xcschemes/Raywenderlich Interview take home.xcscheme @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcuserdata/Yazan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcuserdata/Yazan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..bb33d41 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcuserdata/Yazan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcuserdata/Yazan.xcuserdatad/xcschemes/xcschememanagement.plist b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcuserdata/Yazan.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..228b541 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home.xcodeproj/xcuserdata/Yazan.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,32 @@ + + + + + SchemeUserState + + Raywenderlich Interview take home.xcscheme_^#shared#^_ + + orderHint + 0 + + + SuppressBuildableAutocreation + + ACBDD07228D1201B0075927E + + primary + + + ACBDD08B28D1201C0075927E + + primary + + + ACBDD09528D1201C0075927E + + primary + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/.DS_Store b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/.DS_Store new file mode 100644 index 0000000..9be85f6 Binary files /dev/null and b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/.DS_Store differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/AppDelegate.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/AppDelegate.swift new file mode 100644 index 0000000..b7077d6 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/AppDelegate.swift @@ -0,0 +1,79 @@ +// +// AppDelegate.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import UIKit +import CoreData + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + // MARK: - Core Data stack + + lazy var persistentContainer: NSPersistentContainer = { + /* + The persistent container for the application. This implementation + creates and returns a container, having loaded the store for the + application to it. This property is optional since there are legitimate + error conditions that could cause the creation of the store to fail. + */ + let container = NSPersistentContainer(name: "Raywenderlich_Interview_take_home") + container.loadPersistentStores(completionHandler: { (storeDescription, error) in + if let error = error as NSError? { + // Replace this implementation with code to handle the error appropriately. + // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + + /* + Typical reasons for an error here include: + * The parent directory does not exist, cannot be created, or disallows writing. + * The persistent store is not accessible, due to permissions or data protection when the device is locked. + * The device is out of space. + * The store could not be migrated to the current model version. + Check the error message to determine what the actual problem was. + */ + fatalError("Unresolved error \(error), \(error.userInfo)") + } + }) + return container + }() + + // MARK: - Core Data Saving support + + func saveContext () { + let context = persistentContainer.viewContext + if context.hasChanges { + do { + try context.save() + } catch { + // Replace this implementation with code to handle the error appropriately. + // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + let nserror = error as NSError + fatalError("Unresolved error \(nserror), \(nserror.userInfo)") + } + } + } + +} + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/.DS_Store b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/.DS_Store new file mode 100644 index 0000000..4a6e9c0 Binary files /dev/null and b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/.DS_Store differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/AccentColor.colorset/Contents.json b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/AppIcon.appiconset/Contents.json b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..13613e3 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/Contents.json b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/placeholder.imageset/Contents.json b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/placeholder.imageset/Contents.json new file mode 100644 index 0000000..4c7316b --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/placeholder.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "istockphoto-1147544807-612x612.jpg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/placeholder.imageset/istockphoto-1147544807-612x612.jpg b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/placeholder.imageset/istockphoto-1147544807-612x612.jpg new file mode 100644 index 0000000..2bf6579 Binary files /dev/null and b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Assets.xcassets/placeholder.imageset/istockphoto-1147544807-612x612.jpg differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Base.lproj/LaunchScreen.storyboard b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Core/Extensions/UIImageExtensions.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Core/Extensions/UIImageExtensions.swift new file mode 100644 index 0000000..f7b8387 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Core/Extensions/UIImageExtensions.swift @@ -0,0 +1,48 @@ +// +// UIImageExtensions.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/15/22. +// + +import Foundation +import UIKit +import OSLog + +// We want to have a cache of images to optimize performance and reduce unnecessary network calls +let imageCache = NSCache() + +extension UIImageView { + + /// Loads an image from a url and saves it in cache + /// If the image is already in cache it returns it directly, otherwise fetches it from network + /// - Parameter url: the url of the image + func load(fromURL urlStr: String) { + // Check if image is in cache and retrieve it + if let cachedImage = imageCache.object(forKey: urlStr as NSString) { + image = cachedImage + return + } + + // Otherwise fetch from network + if let url = URL(string: urlStr) { + let dataTask = URLSession.shared.dataTask(with: URLRequest(url: url)) { [weak self] data, response, error in + guard let self = self else { return } + if let error = error { + Logger.networking.error("Failed to retrieve image from url \(urlStr) with error \(error)") + return + } + + guard let data = data else { + Logger.networking.error("Failed to retrieve image from url \(urlStr). Request came back with no data") + return + } + + DispatchQueue.main.async { + self.image = UIImage(data: data) + } + } + dataTask.resume() + } + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Info.plist b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Info.plist new file mode 100644 index 0000000..0eb786d --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Info.plist @@ -0,0 +1,23 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Logging/Logging.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Logging/Logging.swift new file mode 100644 index 0000000..551e20e --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Logging/Logging.swift @@ -0,0 +1,17 @@ +// +// Logging.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import OSLog +import Foundation + +extension Logger { + private static var subsystem = Bundle.main.bundleIdentifier! + + /// Logs the view cycles like viewDidLoad. + static let viewCycle = Logger(subsystem: subsystem, category: "viewcycle") + static let networking = Logger(subsystem: subsystem, category: "networking") +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Models/Resource.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Models/Resource.swift new file mode 100644 index 0000000..27d0091 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Models/Resource.swift @@ -0,0 +1,51 @@ +// +// Article.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation + +struct ResourceData: Decodable { + let data: [Resource] +} + +struct Resource: Decodable { + let id: String + let type: String + let attributes: Attributes + //let links: Links +} + +struct Attributes: Decodable { + let uri: String + let name: String + let description: String + let released_at: String + let free: Bool + let difficulty: Difficulty? + let content_type: ContentType + let duration: Int + let popularity: Float + let technology_triple_string: String + let contributor_string: String + let ordinal: String? + let professional: Bool + let description_plain_text: String + let video_identifier: String? + let parent_name: String? + let card_artwork_url: String +} + +struct Links: Decodable { + let `self`: String +} + +enum Difficulty: String, Decodable { + case beginner, intermediate, advanced +} + +enum ContentType: String, Decodable { + case article, collection +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/Endpoint.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/Endpoint.swift new file mode 100644 index 0000000..4a0bf03 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/Endpoint.swift @@ -0,0 +1,29 @@ +// +// Endpoint.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation + +/// Any endpoint needs to specify the following information. This allows us to house all logic to construct the URL request in the conforming entity. Then a separate entity can perform the actual logic of making the network request +protocol Endpoint { + var httpMethod: HTTPMethod { get } + var scheme: HTTPScheme { get } + var baseURL: String { get } + var path: String { get } + var queryParameters: [URLQueryItem] { get } +} + +enum HTTPMethod: String, Codable { + case get = "GET" + case post = "POST" + case delete = "DELETE" + case patch = "PATCH" + case put = "PUT" +} + +enum HTTPScheme: String, Codable { + case http, https +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/Endpoints/RayWenderlich.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/Endpoints/RayWenderlich.swift new file mode 100644 index 0000000..1fd34ae --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/Endpoints/RayWenderlich.swift @@ -0,0 +1,38 @@ +// +// Articles.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation + +enum RayWenderlich: Endpoint { + case articles + case videos + + var httpMethod: HTTPMethod { + return .get + } + + var scheme: HTTPScheme { + return .https + } + + var baseURL: String { + return "raw.githubusercontent.com" + } + + var path: String { + switch self { + case .articles: + return "/raywenderlich/ios-interview/master/Practical Example/articles.json" + case .videos: + return "/raywenderlich/ios-interview/master/Practical Example/videos.json" + } + } + + var queryParameters: [URLQueryItem] { + return [] + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/NetworkManager.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/NetworkManager.swift new file mode 100644 index 0000000..0ba9c98 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/NetworkManager.swift @@ -0,0 +1,62 @@ +// +// NetworkManager.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation +import OSLog + +protocol MakesNetworkRequests { + func request(endpoint: Endpoint) async -> (Result) +} +enum NetworkError: Error { + // For most apps any network error that happens will be handled the same with a generic error view, but reachability issues are handled specifically with a banner or something letting the user know to check their connection. So I am calling out only those two types of errors + case networkIsNotReachable + case error +} + +final class NetworkManager: MakesNetworkRequests { + static let shared = NetworkManager() + + private init() {} + + private func buildURL(endpoint: Endpoint) -> URLComponents { + var components = URLComponents() + components.scheme = endpoint.scheme.rawValue + components.host = endpoint.baseURL + components.path = endpoint.path + if !endpoint.queryParameters.isEmpty { + components.queryItems = endpoint.queryParameters + } + return components + } + + func request(endpoint: Endpoint) async -> Result { + guard NetworkMonitor.shared.isReachable else { + return .failure(.networkIsNotReachable) + } + let components = buildURL(endpoint: endpoint) + guard let url = components.url else { + Logger.networking.error("Building URL with scheme \(components.scheme ?? "") host \(components.host ?? "") path \(components.path) Failed") + return .failure(.error) + } + + Logger.networking.info("url \(url)") + var urlRequest = URLRequest(url: url) + urlRequest.httpMethod = HTTPMethod.get.rawValue + Logger.networking.info("urlRequest \(urlRequest)") + + do { + // process data + let (data, _) = try await URLSession.shared.data(for: urlRequest) + let responseObject = try JSONDecoder().decode(T.self, from: data) + return .success(responseObject) + } catch { + Logger.networking.error("Network Request to \(components.path) failed with \(error)") + return .failure(.error) + } + } +} + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/ReachabilityMonitor.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/ReachabilityMonitor.swift new file mode 100644 index 0000000..6513afc --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Networking/ReachabilityMonitor.swift @@ -0,0 +1,45 @@ +// +// ReachabilityMonitor.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation +import Network + +class NetworkMonitor { + static let shared = NetworkMonitor() + + let monitor = NWPathMonitor() + private var status: NWPath.Status = .requiresConnection + var isReachable: Bool { status == .satisfied } + var isReachableOnCellular: Bool = true + + private init() { + startMonitoring() + } + + func startMonitoring() { + monitor.pathUpdateHandler = { [weak self] path in + self?.status = path.status + self?.isReachableOnCellular = path.isExpensive + + if path.status == .satisfied { + print("We're connected!") + // post connected notification + } else { + print("No connection.") + // post disconnected notification + } + print(path.isExpensive) + } + + let queue = DispatchQueue(label: "NetworkMonitor") + monitor.start(queue: queue) + } + + func stopMonitoring() { + monitor.cancel() + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Raywenderlich_Interview_take_home.xcdatamodeld/.xccurrentversion b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Raywenderlich_Interview_take_home.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..467fca7 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Raywenderlich_Interview_take_home.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + Raywenderlich_Interview_take_home.xcdatamodel + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Raywenderlich_Interview_take_home.xcdatamodeld/Raywenderlich_Interview_take_home.xcdatamodel/contents b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Raywenderlich_Interview_take_home.xcdatamodeld/Raywenderlich_Interview_take_home.xcdatamodel/contents new file mode 100644 index 0000000..50d2514 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/Raywenderlich_Interview_take_home.xcdatamodeld/Raywenderlich_Interview_take_home.xcdatamodel/contents @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/.DS_Store b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/.DS_Store new file mode 100644 index 0000000..036000b Binary files /dev/null and b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/.DS_Store differ diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceListViewController.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceListViewController.swift new file mode 100644 index 0000000..de5a86b --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceListViewController.swift @@ -0,0 +1,115 @@ +// +// ViewController.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import UIKit +import Combine +import OSLog + +class ResourceListViewController: UIViewController, UITableViewDelegate { + let tableView = UITableView() + let stackView = UIStackView() + let buttonsStackView = UIStackView() + let loadingIndicator = UIActivityIndicatorView() + let viewModel = ResourceListViewModel() + + private var subscriptions = Set() + + override func viewDidLoad() { + super.viewDidLoad() + stackView.axis = .vertical + buttonsStackView.axis = .horizontal + pinStackViewToParentView() + + let articlesButton = UIButton(configuration: .bordered()) + articlesButton.setTitle("Articles", for: .normal) + articlesButton.addTarget(self.viewModel, action: #selector(viewModel.showOnlyArticles), for: .touchUpInside) + let videosButton = UIButton(configuration: .bordered()) + videosButton.setTitle("Videos", for: .normal) + videosButton.addTarget(self.viewModel, action: #selector(viewModel.showOnlyVideos), for: .touchUpInside) + let allButton = UIButton(configuration: .bordered()) + allButton.setTitle("Both", for: .normal) + allButton.addTarget(self.viewModel, action: #selector(viewModel.showAllTypes), for: .touchUpInside) + + buttonsStackView.addArrangedSubview(articlesButton) + buttonsStackView.addArrangedSubview(videosButton) + buttonsStackView.addArrangedSubview(allButton) + + stackView.addArrangedSubview(buttonsStackView) + setupTableView() + startInLoadingState() + fetchData() + } + + private func pinStackViewToParentView() { + view.addSubview(stackView) + stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true + stackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true + stackView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true + stackView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true + } + + private func setupTableView() { + tableView.register(ResourceView.nib, forCellReuseIdentifier: ResourceView.identifier) + tableView.translatesAutoresizingMaskIntoConstraints = false + tableView.dataSource = self + tableView.delegate = self + tableView.rowHeight = UITableView.automaticDimension + tableView.estimatedRowHeight = 250 + stackView.addArrangedSubview(tableView) + tableView.frame = view.bounds + } + + private func startInLoadingState() { + tableView.isHidden = true + view.addSubview(loadingIndicator) + loadingIndicator.isHidden = false + loadingIndicator.color = .black + loadingIndicator.translatesAutoresizingMaskIntoConstraints = false + loadingIndicator.startAnimating() + loadingIndicator.center = self.view.center + } + + private func fetchData() { + subscriptions = [ + viewModel.$resources + .receive(on: DispatchQueue.main) + .sink(receiveValue: { [weak self] _ in + guard let self = self else { return } + self.loadingIndicator.isHidden = true + self.tableView.isHidden = false + self.tableView.reloadData() + }) + ] + Task { + await viewModel.fetchResources() + } + } +} + +extension ResourceListViewController: UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return viewModel.resources.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: ResourceView.identifier, for: indexPath) as? ResourceView else { + Logger.viewCycle.error("Failed to dequeue reusable cell with identifier (Resource) at indexPath \(indexPath.row),\(indexPath.section)") + return UITableViewCell() + } + if indexPath.row >= 0 && indexPath.row < viewModel.resources.count { + let resource = viewModel.resources[indexPath.row] + cell.nameLabel.text = resource.attributes.name + cell.descriptionLabel.text = resource.attributes.description + // Start image with loading + cell.artworkImageView.image = UIImage(named: "placeholder") + cell.artworkImageView.load(fromURL: resource.attributes.card_artwork_url) + cell.typeLabel.text = resource.attributes.content_type.rawValue + } + return cell + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceListViewModel.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceListViewModel.swift new file mode 100644 index 0000000..cb5c4ad --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceListViewModel.swift @@ -0,0 +1,67 @@ +// +// ResourceListViewModel.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation +import Combine + +class ResourceListViewModel: ObservableObject { + @Published private(set) var resources: [Resource] = [] + private(set) var totalResources: [Resource] = [] + private var shownResourceTypes: [ContentType] = [.article, .collection] { + didSet { + resources = totalResources.filter { shownResourceTypes.contains($0.attributes.content_type) + }.sortedByReleaseDate() + } + } + + private let networkManager: MakesNetworkRequests + + init(withNetworkManager networkManager: MakesNetworkRequests = NetworkManager.shared) { + // We dependency inject the network manager so we can mock it for unit testing purposes when needed + self.networkManager = networkManager + } + + func fetchResources() async { + var resources: [Resource] = [] + + // We want to have all network requests fire in parallel and await on all of them + async let articlesFetchResult: Result = networkManager.request(endpoint: RayWenderlich.articles) + async let videosFetchResult: Result = networkManager.request(endpoint: RayWenderlich.videos) + let results = await [articlesFetchResult, videosFetchResult] + + // For now we just add any values that arrived + // TODO Error handling here. Should we show an error if any call fails? or both? + for result in results { + switch result { + case .success(let resourceData): + resources.append(contentsOf: resourceData.data) + case .failure: + return + } + } + self.totalResources.append(contentsOf: resources.sortedByReleaseDate()) + self.showAllTypes() + } + + @objc func showOnlyArticles() { + shownResourceTypes = [.article] + } + + @objc func showOnlyVideos() { + shownResourceTypes = [.collection] + } + + @objc func showAllTypes() { + shownResourceTypes = [.article, .collection] + } +} + +fileprivate extension Array where Element == Resource { + func sortedByReleaseDate() -> [Resource] { + return self.sorted(by: { $0.attributes.released_at.compare($1.attributes.released_at) == .orderedDescending }) + } +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceView.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceView.swift new file mode 100644 index 0000000..05c976d --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceView.swift @@ -0,0 +1,20 @@ +// +// ResourceView.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import Foundation +import UIKit + +class ResourceView: UITableViewCell { + static let identifier = "ResourceView" + + static let nib = UINib(nibName: identifier, bundle: nil) + + @IBOutlet weak var artworkImageView: UIImageView! + @IBOutlet weak var nameLabel: UILabel! + @IBOutlet weak var descriptionLabel: UILabel! + @IBOutlet weak var typeLabel: UILabel! +} diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceView.xib b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceView.xib new file mode 100644 index 0000000..9faf7eb --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/ResourceList/ResourceView.xib @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/SceneDelegate.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/SceneDelegate.swift new file mode 100644 index 0000000..d292be0 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take home/SceneDelegate.swift @@ -0,0 +1,63 @@ +// +// SceneDelegate.swift +// Raywenderlich Interview take home +// +// Created by Yazan Halawa on 9/13/22. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + // If this scene's self.window is nil then set a new UIWindow object to it. + let _ = NetworkMonitor.shared // To start monitoring network reachability + + print("Scene willConnectTo.") + guard let windowScene = (scene as? UIWindowScene) else { return } + window = UIWindow(frame: windowScene.coordinateSpace.bounds) + window?.windowScene = windowScene + window?.rootViewController = ResourceListViewController() + window?.makeKeyAndVisible() + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + + // Save changes in the application's managed object context when the application transitions to the background. + (UIApplication.shared.delegate as? AppDelegate)?.saveContext() + } + + +} + diff --git a/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take homeTests/Raywenderlich_Interview_take_homeTests.swift b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take homeTests/Raywenderlich_Interview_take_homeTests.swift new file mode 100644 index 0000000..611b959 --- /dev/null +++ b/Practical Example/Raywenderlich-interview-Yazan-Halawa-submission/Raywenderlich Interview take homeTests/Raywenderlich_Interview_take_homeTests.swift @@ -0,0 +1,59 @@ +// +// Raywenderlich_Interview_take_homeTests.swift +// Raywenderlich Interview take homeTests +// +// Created by Yazan Halawa on 9/13/22. +// + +import XCTest +@testable import Raywenderlich_Interview_take_home + +final class Raywenderlich_Interview_take_homeTests: XCTestCase { + class MockNetworkManager: MakesNetworkRequests { + let resource1 = Resource(id: "1", type: "type1", attributes: Attributes(uri: "randomURI", name: "randomName", description: "randomDesc", released_at: "2020-03-31T13:00:00.000Z", free: true, difficulty: .beginner, content_type: .article, duration: 2, popularity: 2, technology_triple_string: "", contributor_string: "", ordinal: nil, professional: false, description_plain_text: "", video_identifier: "", parent_name: "", card_artwork_url: "")) + let resource2 = Resource(id: "2", type: "type1", attributes: Attributes(uri: "randomURI", name: "randomName", description: "randomDesc", released_at: "2020-03-29T13:00:00.000Z", free: true, difficulty: .beginner, content_type: .collection, duration: 2, popularity: 2, technology_triple_string: "", contributor_string: "", ordinal: nil, professional: false, description_plain_text: "", video_identifier: "", parent_name: "", card_artwork_url: "")) + let resource3 = Resource(id: "3", type: "type1", attributes: Attributes(uri: "randomURI", name: "randomName", description: "randomDesc", released_at: "2020-03-30T13:00:00.000Z", free: true, difficulty: .beginner, content_type: .collection, duration: 2, popularity: 2, technology_triple_string: "", contributor_string: "", ordinal: nil, professional: false, description_plain_text: "", video_identifier: "", parent_name: "", card_artwork_url: "")) + + func request(endpoint: Endpoint) async -> (Result) { + + let data = ResourceData(data: [resource1, resource2, resource3]) + return .success(data as! T) + } + } + + func testFetchingResourcesReturnsMockValues() async throws { + let viewModel = ResourceListViewModel(withNetworkManager: MockNetworkManager()) + await viewModel.fetchResources() + // Since in the view model we fetch resources which makes a call to request twice we will duplicate the three resources resulting in 6 + assert(viewModel.resources.count == 6) + } + + func testFilteringToOnlyArticlesReturnsOnlyArticles() async throws { + let viewModel = ResourceListViewModel(withNetworkManager: MockNetworkManager()) + await viewModel.fetchResources() + viewModel.showOnlyArticles() + // There are 2 "article" type resources in the mocked data + assert(viewModel.resources.count == 2) + } + + func testFilteringToOnlyVideosReturnsOnlyVideos() async throws { + let viewModel = ResourceListViewModel(withNetworkManager: MockNetworkManager()) + await viewModel.fetchResources() + viewModel.showOnlyVideos() + // There are 4 "collection" type resources in the mocked data + assert(viewModel.resources.count == 4) + } + + func testSortingResourcesByReleaseDate() async throws { + let viewModel = ResourceListViewModel(withNetworkManager: MockNetworkManager()) + await viewModel.fetchResources() + // Since we have duplicates this will be a good test if items released on the same data + // Since in our mock resources we have resource 1 released latest, then resource 3, then 2. We should have that order with each resource repeated back to back + assert(viewModel.resources[0].id == "1") + assert(viewModel.resources[1].id == "1") + assert(viewModel.resources[2].id == "3") + assert(viewModel.resources[3].id == "3") + assert(viewModel.resources[4].id == "2") + assert(viewModel.resources[5].id == "2") + } +}