From 7d97be99973aa4bfba6ba39fbc04d6980a6f8c4c Mon Sep 17 00:00:00 2001 From: Kyle Warren Date: Fri, 20 Aug 2021 08:52:12 -0700 Subject: [PATCH 1/3] CoreData partially finished --- .../project.pbxproj | 431 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../RandomizerController.swift | 19 + .../CoreData/CoreDataStack.swift | 39 ++ .../RandomizerGroups+Convenience.swift | 18 + .../.xccurrentversion | 8 + .../RandomizerGroups.xcdatamodel/contents | 10 + .../Resources/AppDelegate.swift | 81 ++++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 ++++ .../Resources/Assets.xcassets/Contents.json | 6 + .../RandomizerGroups/Resources/Info.plist | 66 +++ .../Resources/SceneDelegate.swift | 55 +++ .../RandomizerGroups/ViewController.swift | 19 + .../Base.lproj/LaunchScreen.storyboard | 25 + .../Storyboard/Base.lproj/Main.storyboard | 75 +++ 17 files changed, 976 insertions(+) create mode 100644 RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj create mode 100644 RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift create mode 100644 RandomizerGroups/RandomizerGroups/CoreData/CoreDataStack.swift create mode 100644 RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups+Convenience.swift create mode 100644 RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/.xccurrentversion create mode 100644 RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/RandomizerGroups.xcdatamodel/contents create mode 100644 RandomizerGroups/RandomizerGroups/Resources/AppDelegate.swift create mode 100644 RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/Contents.json create mode 100644 RandomizerGroups/RandomizerGroups/Resources/Info.plist create mode 100644 RandomizerGroups/RandomizerGroups/Resources/SceneDelegate.swift create mode 100644 RandomizerGroups/RandomizerGroups/ViewController.swift create mode 100644 RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/LaunchScreen.storyboard create mode 100644 RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard diff --git a/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj b/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj new file mode 100644 index 00000000..ce6931e5 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj @@ -0,0 +1,431 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 27FAB42E26CFFE4E0061D6A1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB42D26CFFE4E0061D6A1 /* AppDelegate.swift */; }; + 27FAB43026CFFE4E0061D6A1 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB42F26CFFE4E0061D6A1 /* SceneDelegate.swift */; }; + 27FAB43226CFFE4E0061D6A1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB43126CFFE4E0061D6A1 /* ViewController.swift */; }; + 27FAB43526CFFE4E0061D6A1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27FAB43326CFFE4E0061D6A1 /* Main.storyboard */; }; + 27FAB43826CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB43626CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld */; }; + 27FAB43A26CFFE4F0061D6A1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27FAB43926CFFE4F0061D6A1 /* Assets.xcassets */; }; + 27FAB43D26CFFE4F0061D6A1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27FAB43B26CFFE4F0061D6A1 /* LaunchScreen.storyboard */; }; + 27FAB44C26CFFFC70061D6A1 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB44B26CFFFC70061D6A1 /* CoreDataStack.swift */; }; + 27FAB44E26D0012E0061D6A1 /* RandomizerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */; }; + 27FAB45126D004010061D6A1 /* RandomizerGroups+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 27FAB42A26CFFE4E0061D6A1 /* RandomizerGroups.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RandomizerGroups.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 27FAB42D26CFFE4E0061D6A1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 27FAB42F26CFFE4E0061D6A1 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 27FAB43126CFFE4E0061D6A1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 27FAB43426CFFE4E0061D6A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 27FAB43726CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = RandomizerGroups.xcdatamodel; sourceTree = ""; }; + 27FAB43926CFFE4F0061D6A1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 27FAB43C26CFFE4F0061D6A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 27FAB43E26CFFE4F0061D6A1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 27FAB44B26CFFFC70061D6A1 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; + 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomizerController.swift; sourceTree = ""; }; + 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RandomizerGroups+Convenience.swift"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 27FAB42726CFFE4E0061D6A1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 27FAB42126CFFE4E0061D6A1 = { + isa = PBXGroup; + children = ( + 27FAB42C26CFFE4E0061D6A1 /* RandomizerGroups */, + 27FAB42B26CFFE4E0061D6A1 /* Products */, + ); + sourceTree = ""; + }; + 27FAB42B26CFFE4E0061D6A1 /* Products */ = { + isa = PBXGroup; + children = ( + 27FAB42A26CFFE4E0061D6A1 /* RandomizerGroups.app */, + ); + name = Products; + sourceTree = ""; + }; + 27FAB42C26CFFE4E0061D6A1 /* RandomizerGroups */ = { + isa = PBXGroup; + children = ( + 27FAB44526CFFF390061D6A1 /* CoreData */, + 27FAB44626CFFF470061D6A1 /* Controllers */, + 27FAB44926CFFF590061D6A1 /* Views */, + 27FAB44426CFFE690061D6A1 /* Resources */, + 27FAB43126CFFE4E0061D6A1 /* ViewController.swift */, + ); + path = RandomizerGroups; + sourceTree = ""; + }; + 27FAB44426CFFE690061D6A1 /* Resources */ = { + isa = PBXGroup; + children = ( + 27FAB42D26CFFE4E0061D6A1 /* AppDelegate.swift */, + 27FAB42F26CFFE4E0061D6A1 /* SceneDelegate.swift */, + 27FAB43926CFFE4F0061D6A1 /* Assets.xcassets */, + 27FAB43E26CFFE4F0061D6A1 /* Info.plist */, + ); + path = Resources; + sourceTree = ""; + }; + 27FAB44526CFFF390061D6A1 /* CoreData */ = { + isa = PBXGroup; + children = ( + 27FAB43626CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld */, + 27FAB44B26CFFFC70061D6A1 /* CoreDataStack.swift */, + 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */, + ); + path = CoreData; + sourceTree = ""; + }; + 27FAB44626CFFF470061D6A1 /* Controllers */ = { + isa = PBXGroup; + children = ( + 27FAB44826CFFF510061D6A1 /* ModelController */, + 27FAB44726CFFF4B0061D6A1 /* ViewControllers */, + ); + path = Controllers; + sourceTree = ""; + }; + 27FAB44726CFFF4B0061D6A1 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + ); + path = ViewControllers; + sourceTree = ""; + }; + 27FAB44826CFFF510061D6A1 /* ModelController */ = { + isa = PBXGroup; + children = ( + 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */, + ); + path = ModelController; + sourceTree = ""; + }; + 27FAB44926CFFF590061D6A1 /* Views */ = { + isa = PBXGroup; + children = ( + 27FAB44A26CFFF5C0061D6A1 /* Storyboard */, + ); + path = Views; + sourceTree = ""; + }; + 27FAB44A26CFFF5C0061D6A1 /* Storyboard */ = { + isa = PBXGroup; + children = ( + 27FAB43326CFFE4E0061D6A1 /* Main.storyboard */, + 27FAB43B26CFFE4F0061D6A1 /* LaunchScreen.storyboard */, + ); + path = Storyboard; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 27FAB42926CFFE4E0061D6A1 /* RandomizerGroups */ = { + isa = PBXNativeTarget; + buildConfigurationList = 27FAB44126CFFE4F0061D6A1 /* Build configuration list for PBXNativeTarget "RandomizerGroups" */; + buildPhases = ( + 27FAB42626CFFE4E0061D6A1 /* Sources */, + 27FAB42726CFFE4E0061D6A1 /* Frameworks */, + 27FAB42826CFFE4E0061D6A1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RandomizerGroups; + productName = RandomizerGroups; + productReference = 27FAB42A26CFFE4E0061D6A1 /* RandomizerGroups.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 27FAB42226CFFE4E0061D6A1 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1250; + LastUpgradeCheck = 1250; + TargetAttributes = { + 27FAB42926CFFE4E0061D6A1 = { + CreatedOnToolsVersion = 12.5.1; + }; + }; + }; + buildConfigurationList = 27FAB42526CFFE4E0061D6A1 /* Build configuration list for PBXProject "RandomizerGroups" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 27FAB42126CFFE4E0061D6A1; + productRefGroup = 27FAB42B26CFFE4E0061D6A1 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 27FAB42926CFFE4E0061D6A1 /* RandomizerGroups */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 27FAB42826CFFE4E0061D6A1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27FAB43D26CFFE4F0061D6A1 /* LaunchScreen.storyboard in Resources */, + 27FAB43A26CFFE4F0061D6A1 /* Assets.xcassets in Resources */, + 27FAB43526CFFE4E0061D6A1 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 27FAB42626CFFE4E0061D6A1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 27FAB44C26CFFFC70061D6A1 /* CoreDataStack.swift in Sources */, + 27FAB43826CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld in Sources */, + 27FAB43226CFFE4E0061D6A1 /* ViewController.swift in Sources */, + 27FAB42E26CFFE4E0061D6A1 /* AppDelegate.swift in Sources */, + 27FAB44E26D0012E0061D6A1 /* RandomizerController.swift in Sources */, + 27FAB45126D004010061D6A1 /* RandomizerGroups+Convenience.swift in Sources */, + 27FAB43026CFFE4E0061D6A1 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 27FAB43326CFFE4E0061D6A1 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 27FAB43426CFFE4E0061D6A1 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 27FAB43B26CFFE4F0061D6A1 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 27FAB43C26CFFE4F0061D6A1 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 27FAB43F26CFFE4F0061D6A1 /* 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++14"; + CLANG_CXX_LIBRARY = "libc++"; + 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 = 14.5; + 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; + }; + 27FAB44026CFFE4F0061D6A1 /* 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++14"; + CLANG_CXX_LIBRARY = "libc++"; + 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 = 14.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 27FAB44226CFFE4F0061D6A1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = L97V4TW6MB; + INFOPLIST_FILE = RandomizerGroups/Resources/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.KyleWarren.RandomizerGroups; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 27FAB44326CFFE4F0061D6A1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = L97V4TW6MB; + INFOPLIST_FILE = RandomizerGroups/Resources/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.KyleWarren.RandomizerGroups; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 27FAB42526CFFE4E0061D6A1 /* Build configuration list for PBXProject "RandomizerGroups" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27FAB43F26CFFE4F0061D6A1 /* Debug */, + 27FAB44026CFFE4F0061D6A1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 27FAB44126CFFE4F0061D6A1 /* Build configuration list for PBXNativeTarget "RandomizerGroups" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 27FAB44226CFFE4F0061D6A1 /* Debug */, + 27FAB44326CFFE4F0061D6A1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 27FAB43626CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + 27FAB43726CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodel */, + ); + currentVersion = 27FAB43726CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodel */; + path = RandomizerGroups.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = 27FAB42226CFFE4E0061D6A1 /* Project object */; +} diff --git a/RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift b/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift new file mode 100644 index 00000000..b24f895c --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift @@ -0,0 +1,19 @@ +// +// RandomizerController.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +import CoreData + +class RandomizerGroupsController { + + static let shared = RandomizerGroupsController() + + var people: [Person] = [] + + + + +} // End of Class diff --git a/RandomizerGroups/RandomizerGroups/CoreData/CoreDataStack.swift b/RandomizerGroups/RandomizerGroups/CoreData/CoreDataStack.swift new file mode 100644 index 00000000..37156f51 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/CoreData/CoreDataStack.swift @@ -0,0 +1,39 @@ +// +// CoreDataStack.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +import CoreData + +enum CoreDataStack { + + static let container: NSPersistentContainer = { + + let container = NSPersistentContainer(name: "RandomizerGroups") + + container.loadPersistentStores { storeDescription, error in + if let error = error { + fatalError("Error loading persistent stores \(error)") + } + } + return container + }() + + static var context: NSManagedObjectContext { + container.viewContext + } + + static func saveContext() { + if context.hasChanges { + do{ + try context.save() + } catch { + print("Error saving context \(error)") + } + } + } + +} // End of enum + diff --git a/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups+Convenience.swift b/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups+Convenience.swift new file mode 100644 index 00000000..32f01d40 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups+Convenience.swift @@ -0,0 +1,18 @@ +// +// RandomizerGroups+Convenience.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +import CoreData + +extension Person { + + @discardableResult + convenience init(name: String, isGrouped: Bool = false, context: NSManagedObjectContext = CoreDataStack.context) { + self.init(context: context) + self.name = name + self.isGrouped = isGrouped + } +} diff --git a/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/.xccurrentversion b/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/.xccurrentversion new file mode 100644 index 00000000..1bd9b2a2 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + RandomizerGroups.xcdatamodel + + diff --git a/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/RandomizerGroups.xcdatamodel/contents b/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/RandomizerGroups.xcdatamodel/contents new file mode 100644 index 00000000..b7b302b8 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/CoreData/RandomizerGroups.xcdatamodeld/RandomizerGroups.xcdatamodel/contents @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/RandomizerGroups/RandomizerGroups/Resources/AppDelegate.swift b/RandomizerGroups/RandomizerGroups/Resources/AppDelegate.swift new file mode 100644 index 00000000..38e67dc0 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Resources/AppDelegate.swift @@ -0,0 +1,81 @@ +// +// AppDelegate.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +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: "RandomizerGroups") + 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/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AccentColor.colorset/Contents.json b/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/Contents.json b/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/RandomizerGroups/RandomizerGroups/Resources/Info.plist b/RandomizerGroups/RandomizerGroups/Resources/Info.plist new file mode 100644 index 00000000..5b531f7b --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Resources/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/RandomizerGroups/RandomizerGroups/Resources/SceneDelegate.swift b/RandomizerGroups/RandomizerGroups/Resources/SceneDelegate.swift new file mode 100644 index 00000000..7eba099d --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Resources/SceneDelegate.swift @@ -0,0 +1,55 @@ +// +// SceneDelegate.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +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). + guard let _ = (scene as? UIWindowScene) else { return } + } + + 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/RandomizerGroups/RandomizerGroups/ViewController.swift b/RandomizerGroups/RandomizerGroups/ViewController.swift new file mode 100644 index 00000000..c2e6dfcb --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/ViewController.swift @@ -0,0 +1,19 @@ +// +// ViewController.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} + diff --git a/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/LaunchScreen.storyboard b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard new file mode 100644 index 00000000..fd8c4319 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 80ee364d5d3c7f38ac0992b9d0ab83ce1edcb9bc Mon Sep 17 00:00:00 2001 From: Kyle Warren Date: Fri, 20 Aug 2021 09:17:24 -0700 Subject: [PATCH 2/3] CoreData done --- .../project.pbxproj | 8 +- .../RandomizerController.swift | 29 ++++++- .../RandomizerTableViewController.swift | 75 +++++++++++++++++++ .../RandomizerGroups/ViewController.swift | 19 ----- .../Storyboard/Base.lproj/Main.storyboard | 53 ++++++++++++- 5 files changed, 156 insertions(+), 28 deletions(-) create mode 100644 RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift delete mode 100644 RandomizerGroups/RandomizerGroups/ViewController.swift diff --git a/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj b/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj index ce6931e5..a8a1e23b 100644 --- a/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj +++ b/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 27FAB42E26CFFE4E0061D6A1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB42D26CFFE4E0061D6A1 /* AppDelegate.swift */; }; 27FAB43026CFFE4E0061D6A1 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB42F26CFFE4E0061D6A1 /* SceneDelegate.swift */; }; - 27FAB43226CFFE4E0061D6A1 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB43126CFFE4E0061D6A1 /* ViewController.swift */; }; 27FAB43526CFFE4E0061D6A1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 27FAB43326CFFE4E0061D6A1 /* Main.storyboard */; }; 27FAB43826CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB43626CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld */; }; 27FAB43A26CFFE4F0061D6A1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 27FAB43926CFFE4F0061D6A1 /* Assets.xcassets */; }; @@ -17,13 +16,13 @@ 27FAB44C26CFFFC70061D6A1 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB44B26CFFFC70061D6A1 /* CoreDataStack.swift */; }; 27FAB44E26D0012E0061D6A1 /* RandomizerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */; }; 27FAB45126D004010061D6A1 /* RandomizerGroups+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */; }; + 27FAB45326D0095D0061D6A1 /* RandomizerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB45226D0095D0061D6A1 /* RandomizerTableViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 27FAB42A26CFFE4E0061D6A1 /* RandomizerGroups.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RandomizerGroups.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27FAB42D26CFFE4E0061D6A1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 27FAB42F26CFFE4E0061D6A1 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 27FAB43126CFFE4E0061D6A1 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 27FAB43426CFFE4E0061D6A1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27FAB43726CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = RandomizerGroups.xcdatamodel; sourceTree = ""; }; 27FAB43926CFFE4F0061D6A1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -32,6 +31,7 @@ 27FAB44B26CFFFC70061D6A1 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomizerController.swift; sourceTree = ""; }; 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RandomizerGroups+Convenience.swift"; sourceTree = ""; }; + 27FAB45226D0095D0061D6A1 /* RandomizerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomizerTableViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -68,7 +68,6 @@ 27FAB44626CFFF470061D6A1 /* Controllers */, 27FAB44926CFFF590061D6A1 /* Views */, 27FAB44426CFFE690061D6A1 /* Resources */, - 27FAB43126CFFE4E0061D6A1 /* ViewController.swift */, ); path = RandomizerGroups; sourceTree = ""; @@ -106,6 +105,7 @@ 27FAB44726CFFF4B0061D6A1 /* ViewControllers */ = { isa = PBXGroup; children = ( + 27FAB45226D0095D0061D6A1 /* RandomizerTableViewController.swift */, ); path = ViewControllers; sourceTree = ""; @@ -205,9 +205,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 27FAB45326D0095D0061D6A1 /* RandomizerTableViewController.swift in Sources */, 27FAB44C26CFFFC70061D6A1 /* CoreDataStack.swift in Sources */, 27FAB43826CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld in Sources */, - 27FAB43226CFFE4E0061D6A1 /* ViewController.swift in Sources */, 27FAB42E26CFFE4E0061D6A1 /* AppDelegate.swift in Sources */, 27FAB44E26D0012E0061D6A1 /* RandomizerController.swift in Sources */, 27FAB45126D004010061D6A1 /* RandomizerGroups+Convenience.swift in Sources */, diff --git a/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift b/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift index b24f895c..19fde081 100644 --- a/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift +++ b/RandomizerGroups/RandomizerGroups/Controllers/ModelController/RandomizerController.swift @@ -7,13 +7,38 @@ import CoreData -class RandomizerGroupsController { +class RandomizerController { - static let shared = RandomizerGroupsController() + static let shared = RandomizerController() var people: [Person] = [] + //MARK: - CRUD + func createPersonWith(name: String){ + let newPerson = Person(name: name) + people.append(newPerson) + + CoreDataStack.saveContext() + } + func update(person: Person, name: String) { + person.name = name + + CoreDataStack.saveContext() + } + func toggleIsGrouped(person: Person) { + person.isGrouped.toggle() + + CoreDataStack.saveContext() + } + + func deletePerson(person: Person) { + guard let index = people.firstIndex(of: person) else { return } + people.remove(at: index) + + CoreDataStack.context.delete(person) + CoreDataStack.saveContext() + } } // End of Class diff --git a/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift b/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift new file mode 100644 index 00000000..71153f30 --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift @@ -0,0 +1,75 @@ +// +// RandomizerTableViewController.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +import UIKit + +class RandomizerTableViewController: UITableViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(true) + tableView.reloadData() + } + + // MARK: - Table view data source + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + return RandomizerController.shared.people.count + } + + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "personCell", for: indexPath) + + let person = RandomizerController.shared.people[indexPath.row] + cell.textLabel?.text = person.name + + return cell + } + + + // Override to support editing the table view. + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + // Delete the row from the data source + tableView.deleteRows(at: [indexPath], with: .fade) + } else if editingStyle == .insert { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + + + /* + // Override to support rearranging the table view. + override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { + + } + */ + + /* + // Override to support conditional rearranging of the table view. + override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + // Return false if you do not want the item to be re-orderable. + return true + } + */ + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/RandomizerGroups/RandomizerGroups/ViewController.swift b/RandomizerGroups/RandomizerGroups/ViewController.swift deleted file mode 100644 index c2e6dfcb..00000000 --- a/RandomizerGroups/RandomizerGroups/ViewController.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ViewController.swift -// RandomizerGroups -// -// Created by Kyle Warren on 8/20/21. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - -} - diff --git a/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard index fd8c4319..cf9b5e43 100644 --- a/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard +++ b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + + @@ -16,7 +17,7 @@ - + @@ -41,7 +42,11 @@ - + + + + + @@ -50,6 +55,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From fbc6b163db2d24cf2830376d3afa79d3fcec2c89 Mon Sep 17 00:00:00 2001 From: Kyle Warren Date: Fri, 20 Aug 2021 09:38:33 -0700 Subject: [PATCH 3/3] Detail view, & delete added --- .../project.pbxproj | 4 ++ .../RandomizerDetailViewController.swift | 45 ++++++++++++++++ .../RandomizerTableViewController.swift | 27 +++------- .../Storyboard/Base.lproj/Main.storyboard | 51 ++++++++++--------- 4 files changed, 83 insertions(+), 44 deletions(-) create mode 100644 RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerDetailViewController.swift diff --git a/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj b/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj index a8a1e23b..2c3a4f0e 100644 --- a/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj +++ b/RandomizerGroups/RandomizerGroups.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 27FAB44E26D0012E0061D6A1 /* RandomizerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */; }; 27FAB45126D004010061D6A1 /* RandomizerGroups+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */; }; 27FAB45326D0095D0061D6A1 /* RandomizerTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB45226D0095D0061D6A1 /* RandomizerTableViewController.swift */; }; + 27FAB45526D00EB40061D6A1 /* RandomizerDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FAB45426D00EB40061D6A1 /* RandomizerDetailViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -32,6 +33,7 @@ 27FAB44D26D0012E0061D6A1 /* RandomizerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomizerController.swift; sourceTree = ""; }; 27FAB45026D004010061D6A1 /* RandomizerGroups+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RandomizerGroups+Convenience.swift"; sourceTree = ""; }; 27FAB45226D0095D0061D6A1 /* RandomizerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomizerTableViewController.swift; sourceTree = ""; }; + 27FAB45426D00EB40061D6A1 /* RandomizerDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RandomizerDetailViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -106,6 +108,7 @@ isa = PBXGroup; children = ( 27FAB45226D0095D0061D6A1 /* RandomizerTableViewController.swift */, + 27FAB45426D00EB40061D6A1 /* RandomizerDetailViewController.swift */, ); path = ViewControllers; sourceTree = ""; @@ -209,6 +212,7 @@ 27FAB44C26CFFFC70061D6A1 /* CoreDataStack.swift in Sources */, 27FAB43826CFFE4E0061D6A1 /* RandomizerGroups.xcdatamodeld in Sources */, 27FAB42E26CFFE4E0061D6A1 /* AppDelegate.swift in Sources */, + 27FAB45526D00EB40061D6A1 /* RandomizerDetailViewController.swift in Sources */, 27FAB44E26D0012E0061D6A1 /* RandomizerController.swift in Sources */, 27FAB45126D004010061D6A1 /* RandomizerGroups+Convenience.swift in Sources */, 27FAB43026CFFE4E0061D6A1 /* SceneDelegate.swift in Sources */, diff --git a/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerDetailViewController.swift b/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerDetailViewController.swift new file mode 100644 index 00000000..bbdc799c --- /dev/null +++ b/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerDetailViewController.swift @@ -0,0 +1,45 @@ +// +// RandomizerDetailViewController.swift +// RandomizerGroups +// +// Created by Kyle Warren on 8/20/21. +// + +import UIKit + +class RandomizerDetailViewController: UIViewController { + + //MARK: - OUTLETS + @IBOutlet weak var nameTextField: UITextField! + + + //MARK: - PROPERTIES + var people: Person? + + //MARK: - LIFECYCLES + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + //MARK: - ACTIONS + @IBAction func saveButtonTapped(_ sender: Any) { + guard let name = nameTextField.text, !name.isEmpty else { return } + + if let people = people { + RandomizerController.shared.update(person: people, name: name) + } else { + RandomizerController.shared.createPersonWith(name: name) + } + navigationController?.popViewController(animated: true) + } + + func updateViews() { + guard let people = people else { return } + nameTextField.text = people.name + } + + +} diff --git a/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift b/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift index 71153f30..68002850 100644 --- a/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift +++ b/RandomizerGroups/RandomizerGroups/Controllers/ViewControllers/RandomizerTableViewController.swift @@ -39,29 +39,14 @@ class RandomizerTableViewController: UITableViewController { // Override to support editing the table view. override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { - // Delete the row from the data source + let personToDelete = RandomizerController.shared.people[indexPath.row] + RandomizerController.shared.deletePerson(person: personToDelete) + tableView.deleteRows(at: [indexPath], with: .fade) - } else if editingStyle == .insert { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } + + } } - - - /* - // Override to support rearranging the table view. - override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { - - } - */ - - /* - // Override to support conditional rearranging of the table view. - override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { - // Return false if you do not want the item to be re-orderable. - return true - } - */ - + /* // MARK: - Navigation diff --git a/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard index cf9b5e43..f014bc44 100644 --- a/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard +++ b/RandomizerGroups/RandomizerGroups/Views/Storyboard/Base.lproj/Main.storyboard @@ -11,7 +11,7 @@ - + @@ -41,39 +41,37 @@ - - - - - - - - + + + + + + - + - + - - + + - - + + + + + + + + - +