From c6ecdd7344edacffbdb367454d06c77edb15dcc8 Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Fri, 10 Apr 2020 15:42:06 -0600 Subject: [PATCH 1/7] Added ModelController, TableViewControllera and DetailViewController --- Pair/Pair.xcodeproj/project.pbxproj | 432 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../ModelControllers/StudentController.swift | 86 ++++ .../ListTableViewController.swift | 150 ++++++ .../StudentDetailViewController.swift | 39 ++ Pair/Pair/Models/CoreDataStack.swift | 24 + Pair/Pair/Models/Pair+Convenience.swift | 18 + .../Pair.xcdatamodeld/.xccurrentversion | 8 + .../Pair.xcdatamodel/contents | 9 + Pair/Pair/Resources/AppDelegate.swift | 82 ++++ .../AppIcon.appiconset/Contents.json | 98 ++++ .../Resources/Assets.xcassets/Contents.json | 6 + Pair/Pair/Resources/Info.plist | 64 +++ Pair/Pair/Resources/SceneDelegate.swift | 56 +++ .../Base.lproj/LaunchScreen.storyboard | 25 + .../StoryBoard/Base.lproj/Main.storyboard | 155 +++++++ 17 files changed, 1267 insertions(+) create mode 100644 Pair/Pair.xcodeproj/project.pbxproj create mode 100644 Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Pair/Pair/Controllers/ModelControllers/StudentController.swift create mode 100644 Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift create mode 100644 Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift create mode 100644 Pair/Pair/Models/CoreDataStack.swift create mode 100644 Pair/Pair/Models/Pair+Convenience.swift create mode 100644 Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion create mode 100644 Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents create mode 100644 Pair/Pair/Resources/AppDelegate.swift create mode 100644 Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Pair/Pair/Resources/Assets.xcassets/Contents.json create mode 100644 Pair/Pair/Resources/Info.plist create mode 100644 Pair/Pair/Resources/SceneDelegate.swift create mode 100644 Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard create mode 100644 Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard diff --git a/Pair/Pair.xcodeproj/project.pbxproj b/Pair/Pair.xcodeproj/project.pbxproj new file mode 100644 index 0000000..d57c660 --- /dev/null +++ b/Pair/Pair.xcodeproj/project.pbxproj @@ -0,0 +1,432 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 501B786C2440CE8000122007 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B786B2440CE8000122007 /* AppDelegate.swift */; }; + 501B786E2440CE8000122007 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B786D2440CE8000122007 /* SceneDelegate.swift */; }; + 501B78732440CE8000122007 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 501B78712440CE8000122007 /* Main.storyboard */; }; + 501B78762440CE8000122007 /* Pair.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 501B78742440CE8000122007 /* Pair.xcdatamodeld */; }; + 501B78782440CE8300122007 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 501B78772440CE8300122007 /* Assets.xcassets */; }; + 501B787B2440CE8300122007 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 501B78792440CE8300122007 /* LaunchScreen.storyboard */; }; + 501B788C2440D36E00122007 /* Pair+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B788B2440D36E00122007 /* Pair+Convenience.swift */; }; + 501B788E2440D5ED00122007 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B788D2440D5ED00122007 /* CoreDataStack.swift */; }; + 501B78902440D62E00122007 /* StudentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B788F2440D62E00122007 /* StudentController.swift */; }; + 501B78922440F77C00122007 /* ListTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B78912440F77C00122007 /* ListTableViewController.swift */; }; + 501B78942441019000122007 /* StudentDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B78932441019000122007 /* StudentDetailViewController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 501B78682440CE8000122007 /* Pair.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pair.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 501B786B2440CE8000122007 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 501B786D2440CE8000122007 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 501B78722440CE8000122007 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 501B78752440CE8000122007 /* Pair.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Pair.xcdatamodel; sourceTree = ""; }; + 501B78772440CE8300122007 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 501B787A2440CE8300122007 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 501B787C2440CE8300122007 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 501B788B2440D36E00122007 /* Pair+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Pair+Convenience.swift"; sourceTree = ""; }; + 501B788D2440D5ED00122007 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; + 501B788F2440D62E00122007 /* StudentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentController.swift; sourceTree = ""; }; + 501B78912440F77C00122007 /* ListTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTableViewController.swift; sourceTree = ""; }; + 501B78932441019000122007 /* StudentDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentDetailViewController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 501B78652440CE8000122007 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 501B785F2440CE8000122007 = { + isa = PBXGroup; + children = ( + 501B786A2440CE8000122007 /* Pair */, + 501B78692440CE8000122007 /* Products */, + ); + sourceTree = ""; + }; + 501B78692440CE8000122007 /* Products */ = { + isa = PBXGroup; + children = ( + 501B78682440CE8000122007 /* Pair.app */, + ); + name = Products; + sourceTree = ""; + }; + 501B786A2440CE8000122007 /* Pair */ = { + isa = PBXGroup; + children = ( + 501B78862440CEBE00122007 /* Models */, + 501B78852440CEB900122007 /* Views */, + 501B78842440CEB000122007 /* Controllers */, + 501B78822440CE9C00122007 /* Resources */, + ); + path = Pair; + sourceTree = ""; + }; + 501B78822440CE9C00122007 /* Resources */ = { + isa = PBXGroup; + children = ( + 501B786B2440CE8000122007 /* AppDelegate.swift */, + 501B786D2440CE8000122007 /* SceneDelegate.swift */, + 501B78772440CE8300122007 /* Assets.xcassets */, + 501B787C2440CE8300122007 /* Info.plist */, + ); + path = Resources; + sourceTree = ""; + }; + 501B78842440CEB000122007 /* Controllers */ = { + isa = PBXGroup; + children = ( + 501B788A2440CEFB00122007 /* ModelControllers */, + 501B78892440CEED00122007 /* ViewControllers */, + ); + path = Controllers; + sourceTree = ""; + }; + 501B78852440CEB900122007 /* Views */ = { + isa = PBXGroup; + children = ( + 501B78872440CED100122007 /* StoryBoard */, + ); + path = Views; + sourceTree = ""; + }; + 501B78862440CEBE00122007 /* Models */ = { + isa = PBXGroup; + children = ( + 501B78742440CE8000122007 /* Pair.xcdatamodeld */, + 501B788B2440D36E00122007 /* Pair+Convenience.swift */, + 501B788D2440D5ED00122007 /* CoreDataStack.swift */, + ); + path = Models; + sourceTree = ""; + }; + 501B78872440CED100122007 /* StoryBoard */ = { + isa = PBXGroup; + children = ( + 501B78712440CE8000122007 /* Main.storyboard */, + 501B78792440CE8300122007 /* LaunchScreen.storyboard */, + ); + path = StoryBoard; + sourceTree = ""; + }; + 501B78892440CEED00122007 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 501B78912440F77C00122007 /* ListTableViewController.swift */, + 501B78932441019000122007 /* StudentDetailViewController.swift */, + ); + path = ViewControllers; + sourceTree = ""; + }; + 501B788A2440CEFB00122007 /* ModelControllers */ = { + isa = PBXGroup; + children = ( + 501B788F2440D62E00122007 /* StudentController.swift */, + ); + path = ModelControllers; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 501B78672440CE8000122007 /* Pair */ = { + isa = PBXNativeTarget; + buildConfigurationList = 501B787F2440CE8300122007 /* Build configuration list for PBXNativeTarget "Pair" */; + buildPhases = ( + 501B78642440CE8000122007 /* Sources */, + 501B78652440CE8000122007 /* Frameworks */, + 501B78662440CE8000122007 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Pair; + productName = Pair; + productReference = 501B78682440CE8000122007 /* Pair.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 501B78602440CE8000122007 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1140; + LastUpgradeCheck = 1140; + ORGANIZATIONNAME = AaronPrestidge; + TargetAttributes = { + 501B78672440CE8000122007 = { + CreatedOnToolsVersion = 11.4; + }; + }; + }; + buildConfigurationList = 501B78632440CE8000122007 /* Build configuration list for PBXProject "Pair" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 501B785F2440CE8000122007; + productRefGroup = 501B78692440CE8000122007 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 501B78672440CE8000122007 /* Pair */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 501B78662440CE8000122007 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 501B787B2440CE8300122007 /* LaunchScreen.storyboard in Resources */, + 501B78782440CE8300122007 /* Assets.xcassets in Resources */, + 501B78732440CE8000122007 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 501B78642440CE8000122007 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 501B788E2440D5ED00122007 /* CoreDataStack.swift in Sources */, + 501B78902440D62E00122007 /* StudentController.swift in Sources */, + 501B78762440CE8000122007 /* Pair.xcdatamodeld in Sources */, + 501B788C2440D36E00122007 /* Pair+Convenience.swift in Sources */, + 501B786C2440CE8000122007 /* AppDelegate.swift in Sources */, + 501B786E2440CE8000122007 /* SceneDelegate.swift in Sources */, + 501B78922440F77C00122007 /* ListTableViewController.swift in Sources */, + 501B78942441019000122007 /* StudentDetailViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 501B78712440CE8000122007 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 501B78722440CE8000122007 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 501B78792440CE8300122007 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 501B787A2440CE8300122007 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 501B787D2440CE8300122007 /* 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_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 = 13.4; + 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; + }; + 501B787E2440CE8300122007 /* 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_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 = 13.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 501B78802440CE8300122007 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6XG2KXXAH9; + INFOPLIST_FILE = Pair/Resources/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Pair; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 501B78812440CE8300122007 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6XG2KXXAH9; + INFOPLIST_FILE = Pair/Resources/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Pair; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 501B78632440CE8000122007 /* Build configuration list for PBXProject "Pair" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 501B787D2440CE8300122007 /* Debug */, + 501B787E2440CE8300122007 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 501B787F2440CE8300122007 /* Build configuration list for PBXNativeTarget "Pair" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 501B78802440CE8300122007 /* Debug */, + 501B78812440CE8300122007 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 501B78742440CE8000122007 /* Pair.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + 501B78752440CE8000122007 /* Pair.xcdatamodel */, + ); + currentVersion = 501B78752440CE8000122007 /* Pair.xcdatamodel */; + path = Pair.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = 501B78602440CE8000122007 /* Project object */; +} diff --git a/Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..7259b44 --- /dev/null +++ b/Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Pair/Pair/Controllers/ModelControllers/StudentController.swift b/Pair/Pair/Controllers/ModelControllers/StudentController.swift new file mode 100644 index 0000000..52b16c8 --- /dev/null +++ b/Pair/Pair/Controllers/ModelControllers/StudentController.swift @@ -0,0 +1,86 @@ +// +// StudentController.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import Foundation +import CoreData + +class StudentController { + + //MARK: - Properties + static let shared = StudentController() + + var fetchedResultsController: NSFetchedResultsController + + init() { + let request: NSFetchRequest = Student.fetchRequest() + request.sortDescriptors = [NSSortDescriptor(key: "name", ascending: false)] + let resultsController: NSFetchedResultsController = NSFetchedResultsController(fetchRequest: request, managedObjectContext: CoreDataStack.context, sectionNameKeyPath: nil, cacheName: nil) + fetchedResultsController = resultsController + do { + try fetchedResultsController.performFetch() + } catch { + print("Error performing fetch: \(error), \(error.localizedDescription)\(#function)") + } + } + + //MARK: - CRUD + func create(with name: String) { + Student(name: name) + saveToPersistentStore() + } + + func update(student: Student, name: String) { + student.name = name + saveToPersistentStore() + } + + func delete(student: Student) { + student.managedObjectContext?.delete(student) + saveToPersistentStore() + } + + //MARK: - Persistence + func saveToPersistentStore() { + do { + try CoreDataStack.context.save() + } catch { + print("There was an error performing the fetch: \(error.localizedDescription)\(#function)") + } + } + +}//End Class + +extension ListTableViewController: NSFetchedResultsControllerDelegate { + + func controllerWillChangeContent(_ controller: NSFetchedResultsController) { + tableView.beginUpdates() + } + + func controllerDidChangeContent(_ controller: NSFetchedResultsController) { + tableView.endUpdates() + } + + func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) { + switch type{ + case .delete: + guard let indexPath = indexPath else { break } + tableView.deleteRows(at: [indexPath], with: .fade) + case .insert: + guard let newIndexPath = newIndexPath else { break } + tableView.insertRows(at: [newIndexPath], with: .automatic) + case .move: + guard let indexPath = indexPath, let newIndexPath = newIndexPath else { break } + tableView.moveRow(at: indexPath, to: newIndexPath) + case .update: + guard let indexPath = indexPath else { break } + tableView.reloadRows(at: [indexPath], with: .automatic) + @unknown default: + fatalError() + } + } +} diff --git a/Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift b/Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift new file mode 100644 index 0000000..c8961fc --- /dev/null +++ b/Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift @@ -0,0 +1,150 @@ +// +// ListTableViewController.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit + +class ListTableViewController: UITableViewController { + + //MARK: - Lifecycle + override func viewDidLoad() { + super.viewDidLoad() + StudentController.shared.fetchedResultsController.delegate = self + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + tableView.reloadData() + } + + //MARK: - Actions + @IBAction func createPairsButtonTapped(_ sender: UIBarButtonItem) { + var pairs = StudentController.shared.fetchedResultsController.fetchedObjects + pairs?.shuffle() + tableView.reloadData() + } + + @IBAction func addButtontapped(_ sender: UIBarButtonItem) { + presentAddStudentAlert() + } + + // MARK: - Alert + func presentAddStudentAlert() { + let addAlertController = UIAlertController(title: "Add Student", message: "Add a student to your list.", preferredStyle: .alert) + var newStudentTextField: UITextField? + addAlertController.addTextField { (alertTextField) in + alertTextField.placeholder = "Student name..." + newStudentTextField = alertTextField + } + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + let addAction = UIAlertAction(title: "Add", style: .default) { (_) in + guard let inputText = newStudentTextField?.text else {return} + StudentController.shared.create(with: inputText) + self.tableView.reloadData() + } + addAlertController.addAction(cancelAction) + addAlertController.addAction(addAction) + present(addAlertController, animated: true, completion: nil) + } + + // MARK: - Table view data source + func indexOfCell(indexPath: IndexPath) -> Int { + return (indexPath.section * 2) + indexPath.row + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return "Pair \(section + 1)" + } + + override func numberOfSections(in tableView: UITableView) -> Int { + if (StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) % 2 == 0 { + return (StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) / 2 + } else { + return ((StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) / 2) + 1 + } + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if (StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) % 2 == 0 { + return 2 + } else { + if section == (tableView.numberOfSections - 1) { + return 1 + } else { + return 2 + } + } + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "studentCell", for: indexPath) + let student = StudentController.shared.fetchedResultsController.object(at: indexPath) + cell.textLabel?.text = student.name + return cell + } + + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + let student = StudentController.shared.fetchedResultsController.object(at: indexPath) + StudentController.shared.delete(student: student) + tableView.deleteRows(at: [indexPath], with: .fade) + tableView.reloadData() + } + } + + //MARK: - Navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "toStudentDetailVC" { + guard let indexPath = tableView.indexPathForSelectedRow, + let destination = segue.destination as? StudentDetailViewController else {return} + let student = StudentController.shared.fetchedResultsController.object(at: indexPath) + destination.student = student + } + } + +}//End Class + +extension Array { + mutating func shuffle() { + for _ in 0..<10 { + sort { + (_,_) in arc4random() < arc4random() + } + } + } +}//End Extension + +@IBDesignable extension UIButton { + @IBInspectable var borderWidth: CGFloat { + set { + layer.borderWidth = newValue + } + get { + return layer.borderWidth + } + } + + @IBInspectable var cornerRadius: CGFloat { + set { + layer.cornerRadius = newValue + } + get { + return layer.cornerRadius + } + } + + @IBInspectable var borderColor: UIColor? { + set { + guard let uiColor = newValue else { return } + layer.borderColor = uiColor.cgColor + } + get { + guard let color = layer.borderColor else { return nil } + return UIColor(cgColor: color) + } + } +} diff --git a/Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift b/Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift new file mode 100644 index 0000000..134eba2 --- /dev/null +++ b/Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift @@ -0,0 +1,39 @@ +// +// StudentDetailViewController.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit + +class StudentDetailViewController: UIViewController { + + //MARK: - Properties + var student: Student? + + //MARK: - Outlets + @IBOutlet weak var updateStudentTextField: UITextField! + + //MARK: - Actions + @IBAction func saveButtonTapped(_ sender: UIButton) { + guard let nameText = self.updateStudentTextField.text, + let student = self.student else {return} + StudentController.shared.update(student: student, name: nameText) + } + + @IBAction func cencelButtonTapped(_ sender: UIBarButtonItem) { + dismiss(animated: true, completion: nil) + } + + //MARK: - Lifecycle + override func viewDidLoad() { + super.viewDidLoad() + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + +} diff --git a/Pair/Pair/Models/CoreDataStack.swift b/Pair/Pair/Models/CoreDataStack.swift new file mode 100644 index 0000000..86fd24e --- /dev/null +++ b/Pair/Pair/Models/CoreDataStack.swift @@ -0,0 +1,24 @@ +// +// CoreDataStack.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import Foundation +import CoreData + +enum CoreDataStack { + static let container: NSPersistentContainer = { + let appName = Bundle.main.object(forInfoDictionaryKey: (kCFBundleNameKey as String)) as! String + let container = NSPersistentContainer(name: appName) + container.loadPersistentStores() { (storeDescription, error) in + if let error = error as NSError? { + fatalError("Unresolved error \(error), \(error.userInfo)") + } + } + return container + }() + static var context: NSManagedObjectContext { return container.viewContext } +} diff --git a/Pair/Pair/Models/Pair+Convenience.swift b/Pair/Pair/Models/Pair+Convenience.swift new file mode 100644 index 0000000..0249d93 --- /dev/null +++ b/Pair/Pair/Models/Pair+Convenience.swift @@ -0,0 +1,18 @@ +// +// Pair+Convenience.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import Foundation +import CoreData + +extension Student { + @discardableResult + convenience init(name: String, moc: NSManagedObjectContext = CoreDataStack.context) { + self.init(context: moc) + self.name = name + } +} diff --git a/Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion b/Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..2a3a290 --- /dev/null +++ b/Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + Pair.xcdatamodel + + diff --git a/Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents b/Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents new file mode 100644 index 0000000..c106d27 --- /dev/null +++ b/Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Pair/Pair/Resources/AppDelegate.swift b/Pair/Pair/Resources/AppDelegate.swift new file mode 100644 index 0000000..7cbafc2 --- /dev/null +++ b/Pair/Pair/Resources/AppDelegate.swift @@ -0,0 +1,82 @@ +// +// AppDelegate.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit +import CoreData + +@UIApplicationMain +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: "Pair") + 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/Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/Pair/Pair/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/Pair/Pair/Resources/Assets.xcassets/Contents.json b/Pair/Pair/Resources/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Pair/Pair/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pair/Pair/Resources/Info.plist b/Pair/Pair/Resources/Info.plist new file mode 100644 index 0000000..2a3483c --- /dev/null +++ b/Pair/Pair/Resources/Info.plist @@ -0,0 +1,64 @@ + + + + + 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 + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Pair/Pair/Resources/SceneDelegate.swift b/Pair/Pair/Resources/SceneDelegate.swift new file mode 100644 index 0000000..aa83a59 --- /dev/null +++ b/Pair/Pair/Resources/SceneDelegate.swift @@ -0,0 +1,56 @@ +// +// SceneDelegate.swift +// Pair +// +// Created by Aaron Prestidge on 4/10/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +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 neccessarily 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/Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard b/Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard b/Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard new file mode 100644 index 0000000..a01b9a6 --- /dev/null +++ b/Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From ca6edfce2b567e0daf5240264c2e8b710a617544 Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Thu, 28 May 2020 10:06:22 -0600 Subject: [PATCH 2/7] add Randomizer project file --- .../Randomizer.xcodeproj/project.pbxproj | 360 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + Randomizer/Randomizer/AppDelegate.swift | 82 ++++ .../AppIcon.appiconset/Contents.json | 98 +++++ .../Randomizer/Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../Randomizer/Base.lproj/Main.storyboard | 24 ++ Randomizer/Randomizer/Info.plist | 64 ++++ .../Randomizer.xcdatamodeld/.xccurrentversion | 8 + .../Randomizer.xcdatamodel/contents | 4 + Randomizer/Randomizer/SceneDelegate.swift | 56 +++ Randomizer/Randomizer/ViewController.swift | 20 + 13 files changed, 762 insertions(+) create mode 100644 Randomizer/Randomizer.xcodeproj/project.pbxproj create mode 100644 Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Randomizer/Randomizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Randomizer/Randomizer/AppDelegate.swift create mode 100644 Randomizer/Randomizer/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Randomizer/Randomizer/Assets.xcassets/Contents.json create mode 100644 Randomizer/Randomizer/Base.lproj/LaunchScreen.storyboard create mode 100644 Randomizer/Randomizer/Base.lproj/Main.storyboard create mode 100644 Randomizer/Randomizer/Info.plist create mode 100644 Randomizer/Randomizer/Randomizer.xcdatamodeld/.xccurrentversion create mode 100644 Randomizer/Randomizer/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents create mode 100644 Randomizer/Randomizer/SceneDelegate.swift create mode 100644 Randomizer/Randomizer/ViewController.swift diff --git a/Randomizer/Randomizer.xcodeproj/project.pbxproj b/Randomizer/Randomizer.xcodeproj/project.pbxproj new file mode 100644 index 0000000..28c54c3 --- /dev/null +++ b/Randomizer/Randomizer.xcodeproj/project.pbxproj @@ -0,0 +1,360 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F365E248018D00048C2A8 /* AppDelegate.swift */; }; + 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3660248018D00048C2A8 /* SceneDelegate.swift */; }; + 505F3663248018D00048C2A8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3662248018D00048C2A8 /* ViewController.swift */; }; + 505F3666248018D00048C2A8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F3664248018D00048C2A8 /* Main.storyboard */; }; + 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */; }; + 505F366B248018D10048C2A8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 505F366A248018D10048C2A8 /* Assets.xcassets */; }; + 505F366E248018D10048C2A8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 505F365B248018D00048C2A8 /* Randomizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Randomizer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 505F365E248018D00048C2A8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 505F3660248018D00048C2A8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 505F3662248018D00048C2A8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 505F3665248018D00048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Randomizer.xcdatamodel; sourceTree = ""; }; + 505F366A248018D10048C2A8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 505F366D248018D10048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 505F366F248018D10048C2A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 505F3658248018D00048C2A8 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 505F3652248018D00048C2A8 = { + isa = PBXGroup; + children = ( + 505F365D248018D00048C2A8 /* Randomizer */, + 505F365C248018D00048C2A8 /* Products */, + ); + sourceTree = ""; + }; + 505F365C248018D00048C2A8 /* Products */ = { + isa = PBXGroup; + children = ( + 505F365B248018D00048C2A8 /* Randomizer.app */, + ); + name = Products; + sourceTree = ""; + }; + 505F365D248018D00048C2A8 /* Randomizer */ = { + isa = PBXGroup; + children = ( + 505F365E248018D00048C2A8 /* AppDelegate.swift */, + 505F3660248018D00048C2A8 /* SceneDelegate.swift */, + 505F3662248018D00048C2A8 /* ViewController.swift */, + 505F3664248018D00048C2A8 /* Main.storyboard */, + 505F366A248018D10048C2A8 /* Assets.xcassets */, + 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */, + 505F366F248018D10048C2A8 /* Info.plist */, + 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */, + ); + path = Randomizer; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 505F365A248018D00048C2A8 /* Randomizer */ = { + isa = PBXNativeTarget; + buildConfigurationList = 505F3672248018D10048C2A8 /* Build configuration list for PBXNativeTarget "Randomizer" */; + buildPhases = ( + 505F3657248018D00048C2A8 /* Sources */, + 505F3658248018D00048C2A8 /* Frameworks */, + 505F3659248018D00048C2A8 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Randomizer; + productName = Randomizer; + productReference = 505F365B248018D00048C2A8 /* Randomizer.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 505F3653248018D00048C2A8 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1150; + LastUpgradeCheck = 1150; + ORGANIZATIONNAME = AaronPrestidge; + TargetAttributes = { + 505F365A248018D00048C2A8 = { + CreatedOnToolsVersion = 11.5; + }; + }; + }; + buildConfigurationList = 505F3656248018D00048C2A8 /* Build configuration list for PBXProject "Randomizer" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 505F3652248018D00048C2A8; + productRefGroup = 505F365C248018D00048C2A8 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 505F365A248018D00048C2A8 /* Randomizer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 505F3659248018D00048C2A8 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 505F366E248018D10048C2A8 /* LaunchScreen.storyboard in Resources */, + 505F366B248018D10048C2A8 /* Assets.xcassets in Resources */, + 505F3666248018D00048C2A8 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 505F3657248018D00048C2A8 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 505F3663248018D00048C2A8 /* ViewController.swift in Sources */, + 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */, + 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */, + 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 505F3664248018D00048C2A8 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 505F3665248018D00048C2A8 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 505F366D248018D10048C2A8 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 505F3670248018D10048C2A8 /* 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_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 = 13.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; + }; + 505F3671248018D10048C2A8 /* 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_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 = 13.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; + }; + 505F3673248018D10048C2A8 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6XG2KXXAH9; + INFOPLIST_FILE = Randomizer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Randomizer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 505F3674248018D10048C2A8 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 6XG2KXXAH9; + INFOPLIST_FILE = Randomizer/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Randomizer; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 505F3656248018D00048C2A8 /* Build configuration list for PBXProject "Randomizer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 505F3670248018D10048C2A8 /* Debug */, + 505F3671248018D10048C2A8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 505F3672248018D10048C2A8 /* Build configuration list for PBXNativeTarget "Randomizer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 505F3673248018D10048C2A8 /* Debug */, + 505F3674248018D10048C2A8 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */, + ); + currentVersion = 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */; + path = Randomizer.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = 505F3653248018D00048C2A8 /* Project object */; +} diff --git a/Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9a075f1 --- /dev/null +++ b/Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Randomizer/Randomizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Randomizer/Randomizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Randomizer/Randomizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Randomizer/Randomizer/AppDelegate.swift b/Randomizer/Randomizer/AppDelegate.swift new file mode 100644 index 0000000..52c9115 --- /dev/null +++ b/Randomizer/Randomizer/AppDelegate.swift @@ -0,0 +1,82 @@ +// +// AppDelegate.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit +import CoreData + +@UIApplicationMain +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: "Randomizer") + 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/Randomizer/Randomizer/Assets.xcassets/AppIcon.appiconset/Contents.json b/Randomizer/Randomizer/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/Randomizer/Randomizer/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/Randomizer/Randomizer/Assets.xcassets/Contents.json b/Randomizer/Randomizer/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Randomizer/Randomizer/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Randomizer/Randomizer/Base.lproj/LaunchScreen.storyboard b/Randomizer/Randomizer/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/Randomizer/Randomizer/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Randomizer/Randomizer/Base.lproj/Main.storyboard b/Randomizer/Randomizer/Base.lproj/Main.storyboard new file mode 100644 index 0000000..25a7638 --- /dev/null +++ b/Randomizer/Randomizer/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Randomizer/Randomizer/Info.plist b/Randomizer/Randomizer/Info.plist new file mode 100644 index 0000000..2a3483c --- /dev/null +++ b/Randomizer/Randomizer/Info.plist @@ -0,0 +1,64 @@ + + + + + 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 + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Randomizer/Randomizer/Randomizer.xcdatamodeld/.xccurrentversion b/Randomizer/Randomizer/Randomizer.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..e1b06e3 --- /dev/null +++ b/Randomizer/Randomizer/Randomizer.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + Randomizer.xcdatamodel + + diff --git a/Randomizer/Randomizer/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents b/Randomizer/Randomizer/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents new file mode 100644 index 0000000..50d2514 --- /dev/null +++ b/Randomizer/Randomizer/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Randomizer/Randomizer/SceneDelegate.swift b/Randomizer/Randomizer/SceneDelegate.swift new file mode 100644 index 0000000..afdbb15 --- /dev/null +++ b/Randomizer/Randomizer/SceneDelegate.swift @@ -0,0 +1,56 @@ +// +// SceneDelegate.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +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 neccessarily 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/Randomizer/Randomizer/ViewController.swift b/Randomizer/Randomizer/ViewController.swift new file mode 100644 index 0000000..1b72a84 --- /dev/null +++ b/Randomizer/Randomizer/ViewController.swift @@ -0,0 +1,20 @@ +// +// ViewController.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} + From 37de8f81cbdb11a7b19b02c755c5568262db672d Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Thu, 28 May 2020 10:09:09 -0600 Subject: [PATCH 3/7] Delete old project file --- Pair/Pair.xcodeproj/project.pbxproj | 432 ------------------ .../contents.xcworkspacedata | 7 - .../xcshareddata/IDEWorkspaceChecks.plist | 8 - .../ModelControllers/StudentController.swift | 86 ---- .../ListTableViewController.swift | 150 ------ .../StudentDetailViewController.swift | 39 -- Pair/Pair/Models/CoreDataStack.swift | 24 - Pair/Pair/Models/Pair+Convenience.swift | 18 - .../Pair.xcdatamodeld/.xccurrentversion | 8 - .../Pair.xcdatamodel/contents | 9 - Pair/Pair/Resources/AppDelegate.swift | 82 ---- .../AppIcon.appiconset/Contents.json | 98 ---- .../Resources/Assets.xcassets/Contents.json | 6 - Pair/Pair/Resources/Info.plist | 64 --- Pair/Pair/Resources/SceneDelegate.swift | 56 --- .../Base.lproj/LaunchScreen.storyboard | 25 - .../StoryBoard/Base.lproj/Main.storyboard | 155 ------- 17 files changed, 1267 deletions(-) delete mode 100644 Pair/Pair.xcodeproj/project.pbxproj delete mode 100644 Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Pair/Pair/Controllers/ModelControllers/StudentController.swift delete mode 100644 Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift delete mode 100644 Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift delete mode 100644 Pair/Pair/Models/CoreDataStack.swift delete mode 100644 Pair/Pair/Models/Pair+Convenience.swift delete mode 100644 Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion delete mode 100644 Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents delete mode 100644 Pair/Pair/Resources/AppDelegate.swift delete mode 100644 Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json delete mode 100644 Pair/Pair/Resources/Assets.xcassets/Contents.json delete mode 100644 Pair/Pair/Resources/Info.plist delete mode 100644 Pair/Pair/Resources/SceneDelegate.swift delete mode 100644 Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard delete mode 100644 Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard diff --git a/Pair/Pair.xcodeproj/project.pbxproj b/Pair/Pair.xcodeproj/project.pbxproj deleted file mode 100644 index d57c660..0000000 --- a/Pair/Pair.xcodeproj/project.pbxproj +++ /dev/null @@ -1,432 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 501B786C2440CE8000122007 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B786B2440CE8000122007 /* AppDelegate.swift */; }; - 501B786E2440CE8000122007 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B786D2440CE8000122007 /* SceneDelegate.swift */; }; - 501B78732440CE8000122007 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 501B78712440CE8000122007 /* Main.storyboard */; }; - 501B78762440CE8000122007 /* Pair.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 501B78742440CE8000122007 /* Pair.xcdatamodeld */; }; - 501B78782440CE8300122007 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 501B78772440CE8300122007 /* Assets.xcassets */; }; - 501B787B2440CE8300122007 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 501B78792440CE8300122007 /* LaunchScreen.storyboard */; }; - 501B788C2440D36E00122007 /* Pair+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B788B2440D36E00122007 /* Pair+Convenience.swift */; }; - 501B788E2440D5ED00122007 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B788D2440D5ED00122007 /* CoreDataStack.swift */; }; - 501B78902440D62E00122007 /* StudentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B788F2440D62E00122007 /* StudentController.swift */; }; - 501B78922440F77C00122007 /* ListTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B78912440F77C00122007 /* ListTableViewController.swift */; }; - 501B78942441019000122007 /* StudentDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 501B78932441019000122007 /* StudentDetailViewController.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 501B78682440CE8000122007 /* Pair.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Pair.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 501B786B2440CE8000122007 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 501B786D2440CE8000122007 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 501B78722440CE8000122007 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 501B78752440CE8000122007 /* Pair.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Pair.xcdatamodel; sourceTree = ""; }; - 501B78772440CE8300122007 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 501B787A2440CE8300122007 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 501B787C2440CE8300122007 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 501B788B2440D36E00122007 /* Pair+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Pair+Convenience.swift"; sourceTree = ""; }; - 501B788D2440D5ED00122007 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; - 501B788F2440D62E00122007 /* StudentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentController.swift; sourceTree = ""; }; - 501B78912440F77C00122007 /* ListTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListTableViewController.swift; sourceTree = ""; }; - 501B78932441019000122007 /* StudentDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentDetailViewController.swift; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 501B78652440CE8000122007 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 501B785F2440CE8000122007 = { - isa = PBXGroup; - children = ( - 501B786A2440CE8000122007 /* Pair */, - 501B78692440CE8000122007 /* Products */, - ); - sourceTree = ""; - }; - 501B78692440CE8000122007 /* Products */ = { - isa = PBXGroup; - children = ( - 501B78682440CE8000122007 /* Pair.app */, - ); - name = Products; - sourceTree = ""; - }; - 501B786A2440CE8000122007 /* Pair */ = { - isa = PBXGroup; - children = ( - 501B78862440CEBE00122007 /* Models */, - 501B78852440CEB900122007 /* Views */, - 501B78842440CEB000122007 /* Controllers */, - 501B78822440CE9C00122007 /* Resources */, - ); - path = Pair; - sourceTree = ""; - }; - 501B78822440CE9C00122007 /* Resources */ = { - isa = PBXGroup; - children = ( - 501B786B2440CE8000122007 /* AppDelegate.swift */, - 501B786D2440CE8000122007 /* SceneDelegate.swift */, - 501B78772440CE8300122007 /* Assets.xcassets */, - 501B787C2440CE8300122007 /* Info.plist */, - ); - path = Resources; - sourceTree = ""; - }; - 501B78842440CEB000122007 /* Controllers */ = { - isa = PBXGroup; - children = ( - 501B788A2440CEFB00122007 /* ModelControllers */, - 501B78892440CEED00122007 /* ViewControllers */, - ); - path = Controllers; - sourceTree = ""; - }; - 501B78852440CEB900122007 /* Views */ = { - isa = PBXGroup; - children = ( - 501B78872440CED100122007 /* StoryBoard */, - ); - path = Views; - sourceTree = ""; - }; - 501B78862440CEBE00122007 /* Models */ = { - isa = PBXGroup; - children = ( - 501B78742440CE8000122007 /* Pair.xcdatamodeld */, - 501B788B2440D36E00122007 /* Pair+Convenience.swift */, - 501B788D2440D5ED00122007 /* CoreDataStack.swift */, - ); - path = Models; - sourceTree = ""; - }; - 501B78872440CED100122007 /* StoryBoard */ = { - isa = PBXGroup; - children = ( - 501B78712440CE8000122007 /* Main.storyboard */, - 501B78792440CE8300122007 /* LaunchScreen.storyboard */, - ); - path = StoryBoard; - sourceTree = ""; - }; - 501B78892440CEED00122007 /* ViewControllers */ = { - isa = PBXGroup; - children = ( - 501B78912440F77C00122007 /* ListTableViewController.swift */, - 501B78932441019000122007 /* StudentDetailViewController.swift */, - ); - path = ViewControllers; - sourceTree = ""; - }; - 501B788A2440CEFB00122007 /* ModelControllers */ = { - isa = PBXGroup; - children = ( - 501B788F2440D62E00122007 /* StudentController.swift */, - ); - path = ModelControllers; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 501B78672440CE8000122007 /* Pair */ = { - isa = PBXNativeTarget; - buildConfigurationList = 501B787F2440CE8300122007 /* Build configuration list for PBXNativeTarget "Pair" */; - buildPhases = ( - 501B78642440CE8000122007 /* Sources */, - 501B78652440CE8000122007 /* Frameworks */, - 501B78662440CE8000122007 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Pair; - productName = Pair; - productReference = 501B78682440CE8000122007 /* Pair.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 501B78602440CE8000122007 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1140; - LastUpgradeCheck = 1140; - ORGANIZATIONNAME = AaronPrestidge; - TargetAttributes = { - 501B78672440CE8000122007 = { - CreatedOnToolsVersion = 11.4; - }; - }; - }; - buildConfigurationList = 501B78632440CE8000122007 /* Build configuration list for PBXProject "Pair" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 501B785F2440CE8000122007; - productRefGroup = 501B78692440CE8000122007 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 501B78672440CE8000122007 /* Pair */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 501B78662440CE8000122007 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 501B787B2440CE8300122007 /* LaunchScreen.storyboard in Resources */, - 501B78782440CE8300122007 /* Assets.xcassets in Resources */, - 501B78732440CE8000122007 /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 501B78642440CE8000122007 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 501B788E2440D5ED00122007 /* CoreDataStack.swift in Sources */, - 501B78902440D62E00122007 /* StudentController.swift in Sources */, - 501B78762440CE8000122007 /* Pair.xcdatamodeld in Sources */, - 501B788C2440D36E00122007 /* Pair+Convenience.swift in Sources */, - 501B786C2440CE8000122007 /* AppDelegate.swift in Sources */, - 501B786E2440CE8000122007 /* SceneDelegate.swift in Sources */, - 501B78922440F77C00122007 /* ListTableViewController.swift in Sources */, - 501B78942441019000122007 /* StudentDetailViewController.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 501B78712440CE8000122007 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 501B78722440CE8000122007 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; - 501B78792440CE8300122007 /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 501B787A2440CE8300122007 /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 501B787D2440CE8300122007 /* 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_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 = 13.4; - 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; - }; - 501B787E2440CE8300122007 /* 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_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 = 13.4; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 501B78802440CE8300122007 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6XG2KXXAH9; - INFOPLIST_FILE = Pair/Resources/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Pair; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 501B78812440CE8300122007 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 6XG2KXXAH9; - INFOPLIST_FILE = Pair/Resources/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Pair; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 501B78632440CE8000122007 /* Build configuration list for PBXProject "Pair" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 501B787D2440CE8300122007 /* Debug */, - 501B787E2440CE8300122007 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 501B787F2440CE8300122007 /* Build configuration list for PBXNativeTarget "Pair" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 501B78802440CE8300122007 /* Debug */, - 501B78812440CE8300122007 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - -/* Begin XCVersionGroup section */ - 501B78742440CE8000122007 /* Pair.xcdatamodeld */ = { - isa = XCVersionGroup; - children = ( - 501B78752440CE8000122007 /* Pair.xcdatamodel */, - ); - currentVersion = 501B78752440CE8000122007 /* Pair.xcdatamodel */; - path = Pair.xcdatamodeld; - sourceTree = ""; - versionGroupType = wrapper.xcdatamodel; - }; -/* End XCVersionGroup section */ - }; - rootObject = 501B78602440CE8000122007 /* Project object */; -} diff --git a/Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 7259b44..0000000 --- a/Pair/Pair.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Pair/Pair.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Pair/Pair/Controllers/ModelControllers/StudentController.swift b/Pair/Pair/Controllers/ModelControllers/StudentController.swift deleted file mode 100644 index 52b16c8..0000000 --- a/Pair/Pair/Controllers/ModelControllers/StudentController.swift +++ /dev/null @@ -1,86 +0,0 @@ -// -// StudentController.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import Foundation -import CoreData - -class StudentController { - - //MARK: - Properties - static let shared = StudentController() - - var fetchedResultsController: NSFetchedResultsController - - init() { - let request: NSFetchRequest = Student.fetchRequest() - request.sortDescriptors = [NSSortDescriptor(key: "name", ascending: false)] - let resultsController: NSFetchedResultsController = NSFetchedResultsController(fetchRequest: request, managedObjectContext: CoreDataStack.context, sectionNameKeyPath: nil, cacheName: nil) - fetchedResultsController = resultsController - do { - try fetchedResultsController.performFetch() - } catch { - print("Error performing fetch: \(error), \(error.localizedDescription)\(#function)") - } - } - - //MARK: - CRUD - func create(with name: String) { - Student(name: name) - saveToPersistentStore() - } - - func update(student: Student, name: String) { - student.name = name - saveToPersistentStore() - } - - func delete(student: Student) { - student.managedObjectContext?.delete(student) - saveToPersistentStore() - } - - //MARK: - Persistence - func saveToPersistentStore() { - do { - try CoreDataStack.context.save() - } catch { - print("There was an error performing the fetch: \(error.localizedDescription)\(#function)") - } - } - -}//End Class - -extension ListTableViewController: NSFetchedResultsControllerDelegate { - - func controllerWillChangeContent(_ controller: NSFetchedResultsController) { - tableView.beginUpdates() - } - - func controllerDidChangeContent(_ controller: NSFetchedResultsController) { - tableView.endUpdates() - } - - func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) { - switch type{ - case .delete: - guard let indexPath = indexPath else { break } - tableView.deleteRows(at: [indexPath], with: .fade) - case .insert: - guard let newIndexPath = newIndexPath else { break } - tableView.insertRows(at: [newIndexPath], with: .automatic) - case .move: - guard let indexPath = indexPath, let newIndexPath = newIndexPath else { break } - tableView.moveRow(at: indexPath, to: newIndexPath) - case .update: - guard let indexPath = indexPath else { break } - tableView.reloadRows(at: [indexPath], with: .automatic) - @unknown default: - fatalError() - } - } -} diff --git a/Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift b/Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift deleted file mode 100644 index c8961fc..0000000 --- a/Pair/Pair/Controllers/ViewControllers/ListTableViewController.swift +++ /dev/null @@ -1,150 +0,0 @@ -// -// ListTableViewController.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import UIKit - -class ListTableViewController: UITableViewController { - - //MARK: - Lifecycle - override func viewDidLoad() { - super.viewDidLoad() - StudentController.shared.fetchedResultsController.delegate = self - } - - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - tableView.reloadData() - } - - //MARK: - Actions - @IBAction func createPairsButtonTapped(_ sender: UIBarButtonItem) { - var pairs = StudentController.shared.fetchedResultsController.fetchedObjects - pairs?.shuffle() - tableView.reloadData() - } - - @IBAction func addButtontapped(_ sender: UIBarButtonItem) { - presentAddStudentAlert() - } - - // MARK: - Alert - func presentAddStudentAlert() { - let addAlertController = UIAlertController(title: "Add Student", message: "Add a student to your list.", preferredStyle: .alert) - var newStudentTextField: UITextField? - addAlertController.addTextField { (alertTextField) in - alertTextField.placeholder = "Student name..." - newStudentTextField = alertTextField - } - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - let addAction = UIAlertAction(title: "Add", style: .default) { (_) in - guard let inputText = newStudentTextField?.text else {return} - StudentController.shared.create(with: inputText) - self.tableView.reloadData() - } - addAlertController.addAction(cancelAction) - addAlertController.addAction(addAction) - present(addAlertController, animated: true, completion: nil) - } - - // MARK: - Table view data source - func indexOfCell(indexPath: IndexPath) -> Int { - return (indexPath.section * 2) + indexPath.row - } - - override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { - return "Pair \(section + 1)" - } - - override func numberOfSections(in tableView: UITableView) -> Int { - if (StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) % 2 == 0 { - return (StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) / 2 - } else { - return ((StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) / 2) + 1 - } - } - - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if (StudentController.shared.fetchedResultsController.fetchedObjects?.count ?? 0) % 2 == 0 { - return 2 - } else { - if section == (tableView.numberOfSections - 1) { - return 1 - } else { - return 2 - } - } - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "studentCell", for: indexPath) - let student = StudentController.shared.fetchedResultsController.object(at: indexPath) - cell.textLabel?.text = student.name - return cell - } - - override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { - if editingStyle == .delete { - let student = StudentController.shared.fetchedResultsController.object(at: indexPath) - StudentController.shared.delete(student: student) - tableView.deleteRows(at: [indexPath], with: .fade) - tableView.reloadData() - } - } - - //MARK: - Navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - if segue.identifier == "toStudentDetailVC" { - guard let indexPath = tableView.indexPathForSelectedRow, - let destination = segue.destination as? StudentDetailViewController else {return} - let student = StudentController.shared.fetchedResultsController.object(at: indexPath) - destination.student = student - } - } - -}//End Class - -extension Array { - mutating func shuffle() { - for _ in 0..<10 { - sort { - (_,_) in arc4random() < arc4random() - } - } - } -}//End Extension - -@IBDesignable extension UIButton { - @IBInspectable var borderWidth: CGFloat { - set { - layer.borderWidth = newValue - } - get { - return layer.borderWidth - } - } - - @IBInspectable var cornerRadius: CGFloat { - set { - layer.cornerRadius = newValue - } - get { - return layer.cornerRadius - } - } - - @IBInspectable var borderColor: UIColor? { - set { - guard let uiColor = newValue else { return } - layer.borderColor = uiColor.cgColor - } - get { - guard let color = layer.borderColor else { return nil } - return UIColor(cgColor: color) - } - } -} diff --git a/Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift b/Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift deleted file mode 100644 index 134eba2..0000000 --- a/Pair/Pair/Controllers/ViewControllers/StudentDetailViewController.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// StudentDetailViewController.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import UIKit - -class StudentDetailViewController: UIViewController { - - //MARK: - Properties - var student: Student? - - //MARK: - Outlets - @IBOutlet weak var updateStudentTextField: UITextField! - - //MARK: - Actions - @IBAction func saveButtonTapped(_ sender: UIButton) { - guard let nameText = self.updateStudentTextField.text, - let student = self.student else {return} - StudentController.shared.update(student: student, name: nameText) - } - - @IBAction func cencelButtonTapped(_ sender: UIBarButtonItem) { - dismiss(animated: true, completion: nil) - } - - //MARK: - Lifecycle - override func viewDidLoad() { - super.viewDidLoad() - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - } - -} diff --git a/Pair/Pair/Models/CoreDataStack.swift b/Pair/Pair/Models/CoreDataStack.swift deleted file mode 100644 index 86fd24e..0000000 --- a/Pair/Pair/Models/CoreDataStack.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// CoreDataStack.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import Foundation -import CoreData - -enum CoreDataStack { - static let container: NSPersistentContainer = { - let appName = Bundle.main.object(forInfoDictionaryKey: (kCFBundleNameKey as String)) as! String - let container = NSPersistentContainer(name: appName) - container.loadPersistentStores() { (storeDescription, error) in - if let error = error as NSError? { - fatalError("Unresolved error \(error), \(error.userInfo)") - } - } - return container - }() - static var context: NSManagedObjectContext { return container.viewContext } -} diff --git a/Pair/Pair/Models/Pair+Convenience.swift b/Pair/Pair/Models/Pair+Convenience.swift deleted file mode 100644 index 0249d93..0000000 --- a/Pair/Pair/Models/Pair+Convenience.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// Pair+Convenience.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import Foundation -import CoreData - -extension Student { - @discardableResult - convenience init(name: String, moc: NSManagedObjectContext = CoreDataStack.context) { - self.init(context: moc) - self.name = name - } -} diff --git a/Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion b/Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion deleted file mode 100644 index 2a3a290..0000000 --- a/Pair/Pair/Models/Pair.xcdatamodeld/.xccurrentversion +++ /dev/null @@ -1,8 +0,0 @@ - - - - - _XCCurrentVersionName - Pair.xcdatamodel - - diff --git a/Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents b/Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents deleted file mode 100644 index c106d27..0000000 --- a/Pair/Pair/Models/Pair.xcdatamodeld/Pair.xcdatamodel/contents +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Pair/Pair/Resources/AppDelegate.swift b/Pair/Pair/Resources/AppDelegate.swift deleted file mode 100644 index 7cbafc2..0000000 --- a/Pair/Pair/Resources/AppDelegate.swift +++ /dev/null @@ -1,82 +0,0 @@ -// -// AppDelegate.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import UIKit -import CoreData - -@UIApplicationMain -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: "Pair") - 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/Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 9221b9b..0000000 --- a/Pair/Pair/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "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/Pair/Pair/Resources/Assets.xcassets/Contents.json b/Pair/Pair/Resources/Assets.xcassets/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/Pair/Pair/Resources/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Pair/Pair/Resources/Info.plist b/Pair/Pair/Resources/Info.plist deleted file mode 100644 index 2a3483c..0000000 --- a/Pair/Pair/Resources/Info.plist +++ /dev/null @@ -1,64 +0,0 @@ - - - - - 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 - - - - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/Pair/Pair/Resources/SceneDelegate.swift b/Pair/Pair/Resources/SceneDelegate.swift deleted file mode 100644 index aa83a59..0000000 --- a/Pair/Pair/Resources/SceneDelegate.swift +++ /dev/null @@ -1,56 +0,0 @@ -// -// SceneDelegate.swift -// Pair -// -// Created by Aaron Prestidge on 4/10/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -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 neccessarily 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/Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard b/Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index 865e932..0000000 --- a/Pair/Pair/Views/StoryBoard/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard b/Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard deleted file mode 100644 index a01b9a6..0000000 --- a/Pair/Pair/Views/StoryBoard/Base.lproj/Main.storyboard +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 76f1c909a01acced0ab51c0e0dfce1c92c0a4a23 Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Thu, 28 May 2020 10:24:43 -0600 Subject: [PATCH 4/7] Add Randomizer project file with file structure --- .../Randomizer.xcodeproj/project.pbxproj | 60 ++++++++++++++++--- .../Randomizer.xcdatamodeld/.xccurrentversion | 0 .../Randomizer.xcdatamodel/contents | 0 .../{ => Resources}/AppDelegate.swift | 0 .../AppIcon.appiconset/Contents.json | 0 .../Assets.xcassets/Contents.json | 0 .../Base.lproj/LaunchScreen.storyboard | 0 .../Randomizer/{ => Resources}/Info.plist | 0 .../{ => Resources}/SceneDelegate.swift | 0 .../Base.lproj/Main.storyboard | 0 Randomizer/Randomizer/ViewController.swift | 20 ------- 11 files changed, 52 insertions(+), 28 deletions(-) rename Randomizer/Randomizer/{ => Models}/Randomizer.xcdatamodeld/.xccurrentversion (100%) rename Randomizer/Randomizer/{ => Models}/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents (100%) rename Randomizer/Randomizer/{ => Resources}/AppDelegate.swift (100%) rename Randomizer/Randomizer/{ => Resources}/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename Randomizer/Randomizer/{ => Resources}/Assets.xcassets/Contents.json (100%) rename Randomizer/Randomizer/{ => Resources}/Base.lproj/LaunchScreen.storyboard (100%) rename Randomizer/Randomizer/{ => Resources}/Info.plist (100%) rename Randomizer/Randomizer/{ => Resources}/SceneDelegate.swift (100%) rename Randomizer/Randomizer/{ => StoryboardViews}/Base.lproj/Main.storyboard (100%) delete mode 100644 Randomizer/Randomizer/ViewController.swift diff --git a/Randomizer/Randomizer.xcodeproj/project.pbxproj b/Randomizer/Randomizer.xcodeproj/project.pbxproj index 28c54c3..c990fee 100644 --- a/Randomizer/Randomizer.xcodeproj/project.pbxproj +++ b/Randomizer/Randomizer.xcodeproj/project.pbxproj @@ -9,7 +9,6 @@ /* Begin PBXBuildFile section */ 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F365E248018D00048C2A8 /* AppDelegate.swift */; }; 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3660248018D00048C2A8 /* SceneDelegate.swift */; }; - 505F3663248018D00048C2A8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3662248018D00048C2A8 /* ViewController.swift */; }; 505F3666248018D00048C2A8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F3664248018D00048C2A8 /* Main.storyboard */; }; 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */; }; 505F366B248018D10048C2A8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 505F366A248018D10048C2A8 /* Assets.xcassets */; }; @@ -20,7 +19,6 @@ 505F365B248018D00048C2A8 /* Randomizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Randomizer.app; sourceTree = BUILT_PRODUCTS_DIR; }; 505F365E248018D00048C2A8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 505F3660248018D00048C2A8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 505F3662248018D00048C2A8 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 505F3665248018D00048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Randomizer.xcdatamodel; sourceTree = ""; }; 505F366A248018D10048C2A8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -56,18 +54,65 @@ sourceTree = ""; }; 505F365D248018D00048C2A8 /* Randomizer */ = { + isa = PBXGroup; + children = ( + 505F367624801C500048C2A8 /* Models */, + 505F367724801C5B0048C2A8 /* StoryboardViews */, + 505F367824801C6B0048C2A8 /* Controllers */, + 505F367524801C2C0048C2A8 /* Resources */, + ); + path = Randomizer; + sourceTree = ""; + }; + 505F367524801C2C0048C2A8 /* Resources */ = { isa = PBXGroup; children = ( 505F365E248018D00048C2A8 /* AppDelegate.swift */, 505F3660248018D00048C2A8 /* SceneDelegate.swift */, - 505F3662248018D00048C2A8 /* ViewController.swift */, - 505F3664248018D00048C2A8 /* Main.storyboard */, 505F366A248018D10048C2A8 /* Assets.xcassets */, 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */, 505F366F248018D10048C2A8 /* Info.plist */, + ); + path = Resources; + sourceTree = ""; + }; + 505F367624801C500048C2A8 /* Models */ = { + isa = PBXGroup; + children = ( 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */, ); - path = Randomizer; + path = Models; + sourceTree = ""; + }; + 505F367724801C5B0048C2A8 /* StoryboardViews */ = { + isa = PBXGroup; + children = ( + 505F3664248018D00048C2A8 /* Main.storyboard */, + ); + path = StoryboardViews; + sourceTree = ""; + }; + 505F367824801C6B0048C2A8 /* Controllers */ = { + isa = PBXGroup; + children = ( + 505F367A24801C7C0048C2A8 /* ModelControllers */, + 505F367924801C740048C2A8 /* ViewControllers */, + ); + path = Controllers; + sourceTree = ""; + }; + 505F367924801C740048C2A8 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + ); + path = ViewControllers; + sourceTree = ""; + }; + 505F367A24801C7C0048C2A8 /* ModelControllers */ = { + isa = PBXGroup; + children = ( + ); + path = ModelControllers; sourceTree = ""; }; /* End PBXGroup section */ @@ -141,7 +186,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 505F3663248018D00048C2A8 /* ViewController.swift in Sources */, 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */, 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */, 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */, @@ -290,7 +334,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XG2KXXAH9; - INFOPLIST_FILE = Randomizer/Info.plist; + INFOPLIST_FILE = Randomizer/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -308,7 +352,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XG2KXXAH9; - INFOPLIST_FILE = Randomizer/Info.plist; + INFOPLIST_FILE = Randomizer/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Randomizer/Randomizer/Randomizer.xcdatamodeld/.xccurrentversion b/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/.xccurrentversion similarity index 100% rename from Randomizer/Randomizer/Randomizer.xcdatamodeld/.xccurrentversion rename to Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/.xccurrentversion diff --git a/Randomizer/Randomizer/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents b/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents similarity index 100% rename from Randomizer/Randomizer/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents rename to Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents diff --git a/Randomizer/Randomizer/AppDelegate.swift b/Randomizer/Randomizer/Resources/AppDelegate.swift similarity index 100% rename from Randomizer/Randomizer/AppDelegate.swift rename to Randomizer/Randomizer/Resources/AppDelegate.swift diff --git a/Randomizer/Randomizer/Assets.xcassets/AppIcon.appiconset/Contents.json b/Randomizer/Randomizer/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Randomizer/Randomizer/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Randomizer/Randomizer/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Randomizer/Randomizer/Assets.xcassets/Contents.json b/Randomizer/Randomizer/Resources/Assets.xcassets/Contents.json similarity index 100% rename from Randomizer/Randomizer/Assets.xcassets/Contents.json rename to Randomizer/Randomizer/Resources/Assets.xcassets/Contents.json diff --git a/Randomizer/Randomizer/Base.lproj/LaunchScreen.storyboard b/Randomizer/Randomizer/Resources/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Randomizer/Randomizer/Base.lproj/LaunchScreen.storyboard rename to Randomizer/Randomizer/Resources/Base.lproj/LaunchScreen.storyboard diff --git a/Randomizer/Randomizer/Info.plist b/Randomizer/Randomizer/Resources/Info.plist similarity index 100% rename from Randomizer/Randomizer/Info.plist rename to Randomizer/Randomizer/Resources/Info.plist diff --git a/Randomizer/Randomizer/SceneDelegate.swift b/Randomizer/Randomizer/Resources/SceneDelegate.swift similarity index 100% rename from Randomizer/Randomizer/SceneDelegate.swift rename to Randomizer/Randomizer/Resources/SceneDelegate.swift diff --git a/Randomizer/Randomizer/Base.lproj/Main.storyboard b/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard similarity index 100% rename from Randomizer/Randomizer/Base.lproj/Main.storyboard rename to Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard diff --git a/Randomizer/Randomizer/ViewController.swift b/Randomizer/Randomizer/ViewController.swift deleted file mode 100644 index 1b72a84..0000000 --- a/Randomizer/Randomizer/ViewController.swift +++ /dev/null @@ -1,20 +0,0 @@ -// -// ViewController.swift -// Randomizer -// -// Created by Aaron Prestidge on 5/28/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - -} - From 5a71f28a55109a32cd07b2a76e41762a7b6ad8ba Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Thu, 28 May 2020 10:43:03 -0600 Subject: [PATCH 5/7] Add coreDataStack, Student entity, Student+Convenience.swift --- .../Randomizer.xcodeproj/project.pbxproj | 12 ++++++++ .../ModelControllers/StudentController.swift | 9 ++++++ .../Randomizer/Models/CoreDataStack.swift | 28 +++++++++++++++++++ .../Randomizer.xcdatamodel/contents | 9 ++++-- .../Models/Student+Convenience.swift | 20 +++++++++++++ Randomizer/Randomizer/Resources/Info.plist | 2 -- 6 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift create mode 100644 Randomizer/Randomizer/Models/CoreDataStack.swift create mode 100644 Randomizer/Randomizer/Models/Student+Convenience.swift diff --git a/Randomizer/Randomizer.xcodeproj/project.pbxproj b/Randomizer/Randomizer.xcodeproj/project.pbxproj index c990fee..097bd12 100644 --- a/Randomizer/Randomizer.xcodeproj/project.pbxproj +++ b/Randomizer/Randomizer.xcodeproj/project.pbxproj @@ -13,6 +13,9 @@ 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */; }; 505F366B248018D10048C2A8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 505F366A248018D10048C2A8 /* Assets.xcassets */; }; 505F366E248018D10048C2A8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */; }; + 505F367C24801FD60048C2A8 /* Student+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367B24801FD60048C2A8 /* Student+Convenience.swift */; }; + 505F367E248020630048C2A8 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367D248020630048C2A8 /* CoreDataStack.swift */; }; + 505F3680248021650048C2A8 /* StudentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367F248021650048C2A8 /* StudentController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -24,6 +27,9 @@ 505F366A248018D10048C2A8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 505F366D248018D10048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 505F366F248018D10048C2A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 505F367B24801FD60048C2A8 /* Student+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Student+Convenience.swift"; sourceTree = ""; }; + 505F367D248020630048C2A8 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; + 505F367F248021650048C2A8 /* StudentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -80,6 +86,8 @@ isa = PBXGroup; children = ( 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */, + 505F367B24801FD60048C2A8 /* Student+Convenience.swift */, + 505F367D248020630048C2A8 /* CoreDataStack.swift */, ); path = Models; sourceTree = ""; @@ -111,6 +119,7 @@ 505F367A24801C7C0048C2A8 /* ModelControllers */ = { isa = PBXGroup; children = ( + 505F367F248021650048C2A8 /* StudentController.swift */, ); path = ModelControllers; sourceTree = ""; @@ -186,9 +195,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 505F367E248020630048C2A8 /* CoreDataStack.swift in Sources */, + 505F3680248021650048C2A8 /* StudentController.swift in Sources */, 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */, 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */, 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */, + 505F367C24801FD60048C2A8 /* Student+Convenience.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift b/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift new file mode 100644 index 0000000..d433fc5 --- /dev/null +++ b/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift @@ -0,0 +1,9 @@ +// +// StudentController.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import Foundation diff --git a/Randomizer/Randomizer/Models/CoreDataStack.swift b/Randomizer/Randomizer/Models/CoreDataStack.swift new file mode 100644 index 0000000..01afc17 --- /dev/null +++ b/Randomizer/Randomizer/Models/CoreDataStack.swift @@ -0,0 +1,28 @@ +// +// CoreDataStack.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import CoreData +import Foundation + +enum CoreDataStack { + + static let container: NSPersistentContainer = { + + let appName = Bundle.main.object(forInfoDictionaryKey: (kCFBundleNameKey as String)) as! String + let container = NSPersistentContainer(name: appName) + container.loadPersistentStores() { (storeDescription, error) in + if let error = error as NSError? { + fatalError("Unresolved error \(error), \(error.userInfo)") + } + } + return container + }() + + static var context: NSManagedObjectContext { return container.viewContext } + +}//End enum diff --git a/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents b/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents index 50d2514..113cffb 100644 --- a/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents +++ b/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents @@ -1,4 +1,9 @@ - - + + + + + + + \ No newline at end of file diff --git a/Randomizer/Randomizer/Models/Student+Convenience.swift b/Randomizer/Randomizer/Models/Student+Convenience.swift new file mode 100644 index 0000000..a314ac3 --- /dev/null +++ b/Randomizer/Randomizer/Models/Student+Convenience.swift @@ -0,0 +1,20 @@ +// +// Student+Convenience.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import CoreData +import Foundation + +extension Student { + + @discardableResult + convenience init(name: String, moc: NSManagedObjectContext = CoreDataStack.context) { + self.init(context: moc) + self.name = name + } + +}//End Ext diff --git a/Randomizer/Randomizer/Resources/Info.plist b/Randomizer/Randomizer/Resources/Info.plist index 2a3483c..b5f9c07 100644 --- a/Randomizer/Randomizer/Resources/Info.plist +++ b/Randomizer/Randomizer/Resources/Info.plist @@ -50,8 +50,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad From 5cfeefd928bfb99f30d64efa629ed6d337c5b62c Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Thu, 28 May 2020 12:38:53 -0600 Subject: [PATCH 6/7] Add StudentDetailController, StudentTableViewController and update storyboard. --- .../Randomizer.xcodeproj/project.pbxproj | 10 ++ .../ModelControllers/StudentController.swift | 55 +++++++ .../StudentDetailViewController.swift | 43 ++++++ .../StudentTableViewController.swift | 119 +++++++++++++++ .../Base.lproj/Main.storyboard | 139 ++++++++++++++++-- 5 files changed, 356 insertions(+), 10 deletions(-) create mode 100644 Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift create mode 100644 Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift diff --git a/Randomizer/Randomizer.xcodeproj/project.pbxproj b/Randomizer/Randomizer.xcodeproj/project.pbxproj index 097bd12..230040b 100644 --- a/Randomizer/Randomizer.xcodeproj/project.pbxproj +++ b/Randomizer/Randomizer.xcodeproj/project.pbxproj @@ -16,6 +16,8 @@ 505F367C24801FD60048C2A8 /* Student+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367B24801FD60048C2A8 /* Student+Convenience.swift */; }; 505F367E248020630048C2A8 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367D248020630048C2A8 /* CoreDataStack.swift */; }; 505F3680248021650048C2A8 /* StudentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367F248021650048C2A8 /* StudentController.swift */; }; + 505F3682248029110048C2A8 /* StudentTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3681248029110048C2A8 /* StudentTableViewController.swift */; }; + 505F3684248029360048C2A8 /* StudentDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3683248029360048C2A8 /* StudentDetailViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -30,6 +32,8 @@ 505F367B24801FD60048C2A8 /* Student+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Student+Convenience.swift"; sourceTree = ""; }; 505F367D248020630048C2A8 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; 505F367F248021650048C2A8 /* StudentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentController.swift; sourceTree = ""; }; + 505F3681248029110048C2A8 /* StudentTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentTableViewController.swift; sourceTree = ""; }; + 505F3683248029360048C2A8 /* StudentDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentDetailViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -112,6 +116,8 @@ 505F367924801C740048C2A8 /* ViewControllers */ = { isa = PBXGroup; children = ( + 505F3681248029110048C2A8 /* StudentTableViewController.swift */, + 505F3683248029360048C2A8 /* StudentDetailViewController.swift */, ); path = ViewControllers; sourceTree = ""; @@ -196,11 +202,13 @@ buildActionMask = 2147483647; files = ( 505F367E248020630048C2A8 /* CoreDataStack.swift in Sources */, + 505F3682248029110048C2A8 /* StudentTableViewController.swift in Sources */, 505F3680248021650048C2A8 /* StudentController.swift in Sources */, 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */, 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */, 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */, 505F367C24801FD60048C2A8 /* Student+Convenience.swift in Sources */, + 505F3684248029360048C2A8 /* StudentDetailViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -347,6 +355,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XG2KXXAH9; INFOPLIST_FILE = Randomizer/Resources/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -365,6 +374,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XG2KXXAH9; INFOPLIST_FILE = Randomizer/Resources/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.4; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift b/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift index d433fc5..2ab9de3 100644 --- a/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift +++ b/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift @@ -6,4 +6,59 @@ // Copyright © 2020 AaronPrestidge. All rights reserved. // +import CoreData import Foundation + +class StudentController { + + //MARK: - Shared Instance + static let shared = StudentController() + var students: [Student] = [Student]() + + //MARK: - Initializer + init() { + students = loadFromPersistentStore() + } + + //MARK: - Persistence Functions + private func saveToPersistentStore() { + let moc = CoreDataStack.context + do { + try moc.save() + } catch { + print("Error saving to persistent store \(error), \(error.localizedDescription)") + } + } + + func loadFromPersistentStore() -> [Student] { + let request: NSFetchRequest = Student.fetchRequest() + do { + guard let students = try? CoreDataStack.context.fetch(request) else { return [Student]() } + return students + } catch { + print("Error fetching records from persistent store \(error), \(error.localizedDescription)") + return [] + } + } + + //MARK: - CRUD Functions + func create(name: String) { + Student(name: name) + saveToPersistentStore() + students = loadFromPersistentStore() + } + + func update(student: Student, name: String) { + student.name = name + saveToPersistentStore() + students = loadFromPersistentStore() + } + + func delete(student: Student) { + CoreDataStack.context.delete(student) + saveToPersistentStore() + students = loadFromPersistentStore() + } + + +}//End Class diff --git a/Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift b/Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift new file mode 100644 index 0000000..836e0fe --- /dev/null +++ b/Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift @@ -0,0 +1,43 @@ +// +// StudentDetailViewController.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit + +class StudentDetailViewController: UIViewController { + + //MARK: - Properties + var student: Student? + + //MARK: - Outlets + @IBOutlet weak var nameTextField: UITextField! + + //MARK: - Lifecycle + override func viewDidLoad() { + super.viewDidLoad() + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + } + + //MARK: - Actions + @IBAction func saveButtonTapped(_ sender: UIButton) { + dismiss(animated: true) { + guard let name = self.nameTextField.text, + let student = self.student else { return } + StudentController.shared.update(student: student, name: name) + } + } + + @IBAction func cancelButtonTapped(_ sender: UIBarButtonItem) { + dismiss(animated: true, completion: nil) + } + + +}//End Class diff --git a/Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift b/Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift new file mode 100644 index 0000000..884b3da --- /dev/null +++ b/Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift @@ -0,0 +1,119 @@ +// +// StudentTableViewController.swift +// Randomizer +// +// Created by Aaron Prestidge on 5/28/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import UIKit + +class StudentTableViewController: UITableViewController { + + // MARK: - Lifecycle + override func viewDidLoad() { + super.viewDidLoad() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + tableView.reloadData() + } + + // MARK: - Actions + @IBAction func addButtonTapped(_ sender: UIBarButtonItem) { + presentAddStudentAlert() + tableView.reloadData() + } + + @IBAction func shuffleButtonTapped(_ sender: UIBarButtonItem) { + StudentController.shared.students.shuffle() + tableView.reloadData() + } + + // MARK: - Table view data source + func indexOfCell(indexPath: IndexPath) -> Int { + return (indexPath.section * 2) + indexPath.row + } + + override func numberOfSections(in tableView: UITableView) -> Int { + if StudentController.shared.students.count % 2 == 0 { + return StudentController.shared.students.count / 2 + } else { + return (StudentController.shared.students.count / 2) + 1 + } + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return "Pair \(section + 1)" + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if StudentController.shared.students.count % 2 == 0 { + return 2 + } else { + if section == (tableView.numberOfSections - 1) { + return 1 + } else { + return 2 + } + } + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "studentCell", for: indexPath) + let student = StudentController.shared.students[indexOfCell(indexPath: indexPath)] + cell.textLabel?.text = student.name + return cell + } + + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + let student = StudentController.shared.students[indexOfCell(indexPath: indexPath)] + StudentController.shared.delete(student: student) + tableView.deleteRows(at: [indexPath], with: .fade) + tableView.reloadData() + } + } + + // MARK: - Methods + func presentAddStudentAlert() { + let alertController = UIAlertController(title: "Add Student", message: "Add a new student to the list", preferredStyle: .alert) + var newStudentTextField: UITextField? + alertController.addTextField { (alertTextField) in + alertTextField.placeholder = "Enter name..." + newStudentTextField = alertTextField + } + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + let addAction = UIAlertAction(title: "Add", style: .default) { (_) in + guard let inputText = newStudentTextField?.text else { return } + StudentController.shared.create(name: inputText) + self.tableView.reloadData() + } + alertController.addAction(cancelAction) + alertController.addAction(addAction) + present(alertController, animated: true, completion: nil) + } + + // MARK: - Navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "toUpdateVC" { + guard let indexPath = tableView.indexPathForSelectedRow else { return } + let student = StudentController.shared.students[indexPath.row] + let updateVC = segue.destination as? StudentDetailViewController + updateVC?.student = student + } + } + + +}//End Class + +extension Array { + mutating func shuffle() { + for _ in 0..<10 { + sort { + (_,_) in arc4random() < arc4random() + } + } + } +} diff --git a/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard b/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard index 25a7638..c1413ed 100644 --- a/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard +++ b/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard @@ -1,24 +1,143 @@ - + + - + - - + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + From cae7e3eadcae28924b86ccfe5973828607d51132 Mon Sep 17 00:00:00 2001 From: Aaron Prestidge Date: Fri, 29 May 2020 12:33:05 -0600 Subject: [PATCH 7/7] Added working project --- .../ModelControllers/StudentController.swift | 64 ------ .../StudentPairs.xcodeproj}/project.pbxproj | 214 +++++++++--------- .../contents.xcworkspacedata | 2 +- .../xcshareddata/IDEWorkspaceChecks.plist | 0 .../ModelControllers/StudentController.swift | 83 +++++++ .../StudentDetailViewController.swift | 29 ++- .../StudentsTableViewController.swift | 122 +++++----- .../StudentPairs}/Models/CoreDataStack.swift | 6 +- .../Models/Student+Convenience.swift | 4 +- .../.xccurrentversion | 2 +- .../StudentPairs.xcdatamodel}/contents | 2 +- .../StudentPairs}/Resources/AppDelegate.swift | 6 +- .../AppIcon.appiconset/Contents.json | 0 .../Resources/Assets.xcassets/Contents.json | 0 .../Base.lproj/LaunchScreen.storyboard | 0 .../StudentPairs}/Resources/Info.plist | 12 + .../Resources/SceneDelegate.swift | 1 + .../Base.lproj/Main.storyboard | 151 ++++++------ 18 files changed, 379 insertions(+), 319 deletions(-) delete mode 100644 Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift rename {Randomizer/Randomizer.xcodeproj => StudentPairs/StudentPairs.xcodeproj}/project.pbxproj (57%) rename {Randomizer/Randomizer.xcodeproj => StudentPairs/StudentPairs.xcodeproj}/project.xcworkspace/contents.xcworkspacedata (69%) rename {Randomizer/Randomizer.xcodeproj => StudentPairs/StudentPairs.xcodeproj}/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist (100%) create mode 100644 StudentPairs/StudentPairs/Controllers/ModelControllers/StudentController.swift rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Controllers/ViewControllers/StudentDetailViewController.swift (50%) rename Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift => StudentPairs/StudentPairs/Controllers/ViewControllers/StudentsTableViewController.swift (60%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Models/CoreDataStack.swift (83%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Models/Student+Convenience.swift (85%) rename {Randomizer/Randomizer/Models/Randomizer.xcdatamodeld => StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld}/.xccurrentversion (83%) rename {Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel => StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/StudentPairs.xcdatamodel}/contents (84%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Resources/AppDelegate.swift (96%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json (100%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Resources/Assets.xcassets/Contents.json (100%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Resources/Base.lproj/LaunchScreen.storyboard (100%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Resources/Info.plist (85%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/Resources/SceneDelegate.swift (99%) rename {Randomizer/Randomizer => StudentPairs/StudentPairs}/StoryboardViews/Base.lproj/Main.storyboard (52%) diff --git a/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift b/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift deleted file mode 100644 index 2ab9de3..0000000 --- a/Randomizer/Randomizer/Controllers/ModelControllers/StudentController.swift +++ /dev/null @@ -1,64 +0,0 @@ -// -// StudentController.swift -// Randomizer -// -// Created by Aaron Prestidge on 5/28/20. -// Copyright © 2020 AaronPrestidge. All rights reserved. -// - -import CoreData -import Foundation - -class StudentController { - - //MARK: - Shared Instance - static let shared = StudentController() - var students: [Student] = [Student]() - - //MARK: - Initializer - init() { - students = loadFromPersistentStore() - } - - //MARK: - Persistence Functions - private func saveToPersistentStore() { - let moc = CoreDataStack.context - do { - try moc.save() - } catch { - print("Error saving to persistent store \(error), \(error.localizedDescription)") - } - } - - func loadFromPersistentStore() -> [Student] { - let request: NSFetchRequest = Student.fetchRequest() - do { - guard let students = try? CoreDataStack.context.fetch(request) else { return [Student]() } - return students - } catch { - print("Error fetching records from persistent store \(error), \(error.localizedDescription)") - return [] - } - } - - //MARK: - CRUD Functions - func create(name: String) { - Student(name: name) - saveToPersistentStore() - students = loadFromPersistentStore() - } - - func update(student: Student, name: String) { - student.name = name - saveToPersistentStore() - students = loadFromPersistentStore() - } - - func delete(student: Student) { - CoreDataStack.context.delete(student) - saveToPersistentStore() - students = loadFromPersistentStore() - } - - -}//End Class diff --git a/Randomizer/Randomizer.xcodeproj/project.pbxproj b/StudentPairs/StudentPairs.xcodeproj/project.pbxproj similarity index 57% rename from Randomizer/Randomizer.xcodeproj/project.pbxproj rename to StudentPairs/StudentPairs.xcodeproj/project.pbxproj index 230040b..28495f9 100644 --- a/Randomizer/Randomizer.xcodeproj/project.pbxproj +++ b/StudentPairs/StudentPairs.xcodeproj/project.pbxproj @@ -7,37 +7,37 @@ objects = { /* Begin PBXBuildFile section */ - 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F365E248018D00048C2A8 /* AppDelegate.swift */; }; - 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3660248018D00048C2A8 /* SceneDelegate.swift */; }; - 505F3666248018D00048C2A8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F3664248018D00048C2A8 /* Main.storyboard */; }; - 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */; }; - 505F366B248018D10048C2A8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 505F366A248018D10048C2A8 /* Assets.xcassets */; }; - 505F366E248018D10048C2A8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */; }; - 505F367C24801FD60048C2A8 /* Student+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367B24801FD60048C2A8 /* Student+Convenience.swift */; }; - 505F367E248020630048C2A8 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367D248020630048C2A8 /* CoreDataStack.swift */; }; - 505F3680248021650048C2A8 /* StudentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F367F248021650048C2A8 /* StudentController.swift */; }; - 505F3682248029110048C2A8 /* StudentTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3681248029110048C2A8 /* StudentTableViewController.swift */; }; - 505F3684248029360048C2A8 /* StudentDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F3683248029360048C2A8 /* StudentDetailViewController.swift */; }; + 505F369224817D870048C2A8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F369124817D870048C2A8 /* AppDelegate.swift */; }; + 505F369524817D870048C2A8 /* StudentPairs.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 505F369324817D870048C2A8 /* StudentPairs.xcdatamodeld */; }; + 505F369724817D870048C2A8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F369624817D870048C2A8 /* SceneDelegate.swift */; }; + 505F369E24817D870048C2A8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F369C24817D870048C2A8 /* Main.storyboard */; }; + 505F36A024817D890048C2A8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 505F369F24817D890048C2A8 /* Assets.xcassets */; }; + 505F36A324817D8A0048C2A8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 505F36A124817D890048C2A8 /* LaunchScreen.storyboard */; }; + 505F36B124817E6D0048C2A8 /* StudentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F36B024817E6D0048C2A8 /* StudentController.swift */; }; + 505F36B324817E7D0048C2A8 /* StudentDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F36B224817E7D0048C2A8 /* StudentDetailViewController.swift */; }; + 505F36B524817E8E0048C2A8 /* StudentsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F36B424817E8E0048C2A8 /* StudentsTableViewController.swift */; }; + 505F36B724817EA70048C2A8 /* CoreDataStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F36B624817EA70048C2A8 /* CoreDataStack.swift */; }; + 505F36B924817EB60048C2A8 /* Student+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 505F36B824817EB60048C2A8 /* Student+Convenience.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 505F365B248018D00048C2A8 /* Randomizer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Randomizer.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 505F365E248018D00048C2A8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 505F3660248018D00048C2A8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - 505F3665248018D00048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Randomizer.xcdatamodel; sourceTree = ""; }; - 505F366A248018D10048C2A8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 505F366D248018D10048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 505F366F248018D10048C2A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 505F367B24801FD60048C2A8 /* Student+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Student+Convenience.swift"; sourceTree = ""; }; - 505F367D248020630048C2A8 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; - 505F367F248021650048C2A8 /* StudentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentController.swift; sourceTree = ""; }; - 505F3681248029110048C2A8 /* StudentTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentTableViewController.swift; sourceTree = ""; }; - 505F3683248029360048C2A8 /* StudentDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentDetailViewController.swift; sourceTree = ""; }; + 505F368E24817D870048C2A8 /* StudentPairs.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StudentPairs.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 505F369124817D870048C2A8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 505F369424817D870048C2A8 /* StudentPairs.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = StudentPairs.xcdatamodel; sourceTree = ""; }; + 505F369624817D870048C2A8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 505F369D24817D870048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 505F369F24817D890048C2A8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 505F36A224817D890048C2A8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 505F36A424817D8A0048C2A8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 505F36B024817E6D0048C2A8 /* StudentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentController.swift; sourceTree = ""; }; + 505F36B224817E7D0048C2A8 /* StudentDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentDetailViewController.swift; sourceTree = ""; }; + 505F36B424817E8E0048C2A8 /* StudentsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentsTableViewController.swift; sourceTree = ""; }; + 505F36B624817EA70048C2A8 /* CoreDataStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataStack.swift; sourceTree = ""; }; + 505F36B824817EB60048C2A8 /* Student+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Student+Convenience.swift"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 505F3658248018D00048C2A8 /* Frameworks */ = { + 505F368B24817D870048C2A8 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( @@ -47,85 +47,85 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 505F3652248018D00048C2A8 = { + 505F368524817D870048C2A8 = { isa = PBXGroup; children = ( - 505F365D248018D00048C2A8 /* Randomizer */, - 505F365C248018D00048C2A8 /* Products */, + 505F369024817D870048C2A8 /* StudentPairs */, + 505F368F24817D870048C2A8 /* Products */, ); sourceTree = ""; }; - 505F365C248018D00048C2A8 /* Products */ = { + 505F368F24817D870048C2A8 /* Products */ = { isa = PBXGroup; children = ( - 505F365B248018D00048C2A8 /* Randomizer.app */, + 505F368E24817D870048C2A8 /* StudentPairs.app */, ); name = Products; sourceTree = ""; }; - 505F365D248018D00048C2A8 /* Randomizer */ = { + 505F369024817D870048C2A8 /* StudentPairs */ = { isa = PBXGroup; children = ( - 505F367624801C500048C2A8 /* Models */, - 505F367724801C5B0048C2A8 /* StoryboardViews */, - 505F367824801C6B0048C2A8 /* Controllers */, - 505F367524801C2C0048C2A8 /* Resources */, + 505F36AB24817E0A0048C2A8 /* Models */, + 505F36AC24817E0F0048C2A8 /* StoryboardViews */, + 505F36AD24817E180048C2A8 /* Controllers */, + 505F36AA24817D910048C2A8 /* Resources */, ); - path = Randomizer; + path = StudentPairs; sourceTree = ""; }; - 505F367524801C2C0048C2A8 /* Resources */ = { + 505F36AA24817D910048C2A8 /* Resources */ = { isa = PBXGroup; children = ( - 505F365E248018D00048C2A8 /* AppDelegate.swift */, - 505F3660248018D00048C2A8 /* SceneDelegate.swift */, - 505F366A248018D10048C2A8 /* Assets.xcassets */, - 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */, - 505F366F248018D10048C2A8 /* Info.plist */, + 505F369124817D870048C2A8 /* AppDelegate.swift */, + 505F369624817D870048C2A8 /* SceneDelegate.swift */, + 505F369F24817D890048C2A8 /* Assets.xcassets */, + 505F36A124817D890048C2A8 /* LaunchScreen.storyboard */, + 505F36A424817D8A0048C2A8 /* Info.plist */, ); path = Resources; sourceTree = ""; }; - 505F367624801C500048C2A8 /* Models */ = { + 505F36AB24817E0A0048C2A8 /* Models */ = { isa = PBXGroup; children = ( - 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */, - 505F367B24801FD60048C2A8 /* Student+Convenience.swift */, - 505F367D248020630048C2A8 /* CoreDataStack.swift */, + 505F369324817D870048C2A8 /* StudentPairs.xcdatamodeld */, + 505F36B824817EB60048C2A8 /* Student+Convenience.swift */, + 505F36B624817EA70048C2A8 /* CoreDataStack.swift */, ); path = Models; sourceTree = ""; }; - 505F367724801C5B0048C2A8 /* StoryboardViews */ = { + 505F36AC24817E0F0048C2A8 /* StoryboardViews */ = { isa = PBXGroup; children = ( - 505F3664248018D00048C2A8 /* Main.storyboard */, + 505F369C24817D870048C2A8 /* Main.storyboard */, ); path = StoryboardViews; sourceTree = ""; }; - 505F367824801C6B0048C2A8 /* Controllers */ = { + 505F36AD24817E180048C2A8 /* Controllers */ = { isa = PBXGroup; children = ( - 505F367A24801C7C0048C2A8 /* ModelControllers */, - 505F367924801C740048C2A8 /* ViewControllers */, + 505F36AF24817E2E0048C2A8 /* ModelControllers */, + 505F36AE24817E270048C2A8 /* ViewControllers */, ); path = Controllers; sourceTree = ""; }; - 505F367924801C740048C2A8 /* ViewControllers */ = { + 505F36AE24817E270048C2A8 /* ViewControllers */ = { isa = PBXGroup; children = ( - 505F3681248029110048C2A8 /* StudentTableViewController.swift */, - 505F3683248029360048C2A8 /* StudentDetailViewController.swift */, + 505F36B424817E8E0048C2A8 /* StudentsTableViewController.swift */, + 505F36B224817E7D0048C2A8 /* StudentDetailViewController.swift */, ); path = ViewControllers; sourceTree = ""; }; - 505F367A24801C7C0048C2A8 /* ModelControllers */ = { + 505F36AF24817E2E0048C2A8 /* ModelControllers */ = { isa = PBXGroup; children = ( - 505F367F248021650048C2A8 /* StudentController.swift */, + 505F36B024817E6D0048C2A8 /* StudentController.swift */, ); path = ModelControllers; sourceTree = ""; @@ -133,39 +133,39 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 505F365A248018D00048C2A8 /* Randomizer */ = { + 505F368D24817D870048C2A8 /* StudentPairs */ = { isa = PBXNativeTarget; - buildConfigurationList = 505F3672248018D10048C2A8 /* Build configuration list for PBXNativeTarget "Randomizer" */; + buildConfigurationList = 505F36A724817D8A0048C2A8 /* Build configuration list for PBXNativeTarget "StudentPairs" */; buildPhases = ( - 505F3657248018D00048C2A8 /* Sources */, - 505F3658248018D00048C2A8 /* Frameworks */, - 505F3659248018D00048C2A8 /* Resources */, + 505F368A24817D870048C2A8 /* Sources */, + 505F368B24817D870048C2A8 /* Frameworks */, + 505F368C24817D870048C2A8 /* Resources */, ); buildRules = ( ); dependencies = ( ); - name = Randomizer; - productName = Randomizer; - productReference = 505F365B248018D00048C2A8 /* Randomizer.app */; + name = StudentPairs; + productName = StudentPairs; + productReference = 505F368E24817D870048C2A8 /* StudentPairs.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - 505F3653248018D00048C2A8 /* Project object */ = { + 505F368624817D870048C2A8 /* Project object */ = { isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1150; LastUpgradeCheck = 1150; ORGANIZATIONNAME = AaronPrestidge; TargetAttributes = { - 505F365A248018D00048C2A8 = { + 505F368D24817D870048C2A8 = { CreatedOnToolsVersion = 11.5; }; }; }; - buildConfigurationList = 505F3656248018D00048C2A8 /* Build configuration list for PBXProject "Randomizer" */; + buildConfigurationList = 505F368924817D870048C2A8 /* Build configuration list for PBXProject "StudentPairs" */; compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; @@ -173,60 +173,60 @@ en, Base, ); - mainGroup = 505F3652248018D00048C2A8; - productRefGroup = 505F365C248018D00048C2A8 /* Products */; + mainGroup = 505F368524817D870048C2A8; + productRefGroup = 505F368F24817D870048C2A8 /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - 505F365A248018D00048C2A8 /* Randomizer */, + 505F368D24817D870048C2A8 /* StudentPairs */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 505F3659248018D00048C2A8 /* Resources */ = { + 505F368C24817D870048C2A8 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 505F366E248018D10048C2A8 /* LaunchScreen.storyboard in Resources */, - 505F366B248018D10048C2A8 /* Assets.xcassets in Resources */, - 505F3666248018D00048C2A8 /* Main.storyboard in Resources */, + 505F36A324817D8A0048C2A8 /* LaunchScreen.storyboard in Resources */, + 505F36A024817D890048C2A8 /* Assets.xcassets in Resources */, + 505F369E24817D870048C2A8 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - 505F3657248018D00048C2A8 /* Sources */ = { + 505F368A24817D870048C2A8 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 505F367E248020630048C2A8 /* CoreDataStack.swift in Sources */, - 505F3682248029110048C2A8 /* StudentTableViewController.swift in Sources */, - 505F3680248021650048C2A8 /* StudentController.swift in Sources */, - 505F365F248018D00048C2A8 /* AppDelegate.swift in Sources */, - 505F3669248018D00048C2A8 /* Randomizer.xcdatamodeld in Sources */, - 505F3661248018D00048C2A8 /* SceneDelegate.swift in Sources */, - 505F367C24801FD60048C2A8 /* Student+Convenience.swift in Sources */, - 505F3684248029360048C2A8 /* StudentDetailViewController.swift in Sources */, + 505F36B724817EA70048C2A8 /* CoreDataStack.swift in Sources */, + 505F369224817D870048C2A8 /* AppDelegate.swift in Sources */, + 505F36B124817E6D0048C2A8 /* StudentController.swift in Sources */, + 505F36B924817EB60048C2A8 /* Student+Convenience.swift in Sources */, + 505F36B324817E7D0048C2A8 /* StudentDetailViewController.swift in Sources */, + 505F36B524817E8E0048C2A8 /* StudentsTableViewController.swift in Sources */, + 505F369524817D870048C2A8 /* StudentPairs.xcdatamodeld in Sources */, + 505F369724817D870048C2A8 /* SceneDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 505F3664248018D00048C2A8 /* Main.storyboard */ = { + 505F369C24817D870048C2A8 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - 505F3665248018D00048C2A8 /* Base */, + 505F369D24817D870048C2A8 /* Base */, ); name = Main.storyboard; sourceTree = ""; }; - 505F366C248018D10048C2A8 /* LaunchScreen.storyboard */ = { + 505F36A124817D890048C2A8 /* LaunchScreen.storyboard */ = { isa = PBXVariantGroup; children = ( - 505F366D248018D10048C2A8 /* Base */, + 505F36A224817D890048C2A8 /* Base */, ); name = LaunchScreen.storyboard; sourceTree = ""; @@ -234,7 +234,7 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 505F3670248018D10048C2A8 /* Debug */ = { + 505F36A524817D8A0048C2A8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -294,7 +294,7 @@ }; name = Debug; }; - 505F3671248018D10048C2A8 /* Release */ = { + 505F36A624817D8A0048C2A8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -348,38 +348,36 @@ }; name = Release; }; - 505F3673248018D10048C2A8 /* Debug */ = { + 505F36A824817D8A0048C2A8 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XG2KXXAH9; - INFOPLIST_FILE = Randomizer/Resources/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + INFOPLIST_FILE = StudentPairs/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Randomizer; + PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.StudentPairs; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - 505F3674248018D10048C2A8 /* Release */ = { + 505F36A924817D8A0048C2A8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 6XG2KXXAH9; - INFOPLIST_FILE = Randomizer/Resources/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + INFOPLIST_FILE = StudentPairs/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.Randomizer; + PRODUCT_BUNDLE_IDENTIFIER = AaronPrestidge.StudentPairs; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -389,20 +387,20 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 505F3656248018D00048C2A8 /* Build configuration list for PBXProject "Randomizer" */ = { + 505F368924817D870048C2A8 /* Build configuration list for PBXProject "StudentPairs" */ = { isa = XCConfigurationList; buildConfigurations = ( - 505F3670248018D10048C2A8 /* Debug */, - 505F3671248018D10048C2A8 /* Release */, + 505F36A524817D8A0048C2A8 /* Debug */, + 505F36A624817D8A0048C2A8 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 505F3672248018D10048C2A8 /* Build configuration list for PBXNativeTarget "Randomizer" */ = { + 505F36A724817D8A0048C2A8 /* Build configuration list for PBXNativeTarget "StudentPairs" */ = { isa = XCConfigurationList; buildConfigurations = ( - 505F3673248018D10048C2A8 /* Debug */, - 505F3674248018D10048C2A8 /* Release */, + 505F36A824817D8A0048C2A8 /* Debug */, + 505F36A924817D8A0048C2A8 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -410,17 +408,17 @@ /* End XCConfigurationList section */ /* Begin XCVersionGroup section */ - 505F3667248018D00048C2A8 /* Randomizer.xcdatamodeld */ = { + 505F369324817D870048C2A8 /* StudentPairs.xcdatamodeld */ = { isa = XCVersionGroup; children = ( - 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */, + 505F369424817D870048C2A8 /* StudentPairs.xcdatamodel */, ); - currentVersion = 505F3668248018D00048C2A8 /* Randomizer.xcdatamodel */; - path = Randomizer.xcdatamodeld; + currentVersion = 505F369424817D870048C2A8 /* StudentPairs.xcdatamodel */; + path = StudentPairs.xcdatamodeld; sourceTree = ""; versionGroupType = wrapper.xcdatamodel; }; /* End XCVersionGroup section */ }; - rootObject = 505F3653248018D00048C2A8 /* Project object */; + rootObject = 505F368624817D870048C2A8 /* Project object */; } diff --git a/Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/StudentPairs/StudentPairs.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 69% rename from Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to StudentPairs/StudentPairs.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 9a075f1..44377d4 100644 --- a/Randomizer/Randomizer.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/StudentPairs/StudentPairs.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:StudentPairs.xcodeproj"> diff --git a/Randomizer/Randomizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/StudentPairs/StudentPairs.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from Randomizer/Randomizer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to StudentPairs/StudentPairs.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/StudentPairs/StudentPairs/Controllers/ModelControllers/StudentController.swift b/StudentPairs/StudentPairs/Controllers/ModelControllers/StudentController.swift new file mode 100644 index 0000000..a8ad66b --- /dev/null +++ b/StudentPairs/StudentPairs/Controllers/ModelControllers/StudentController.swift @@ -0,0 +1,83 @@ +// +// StudentController.swift +// StudentPairs +// +// Created by Aaron Prestidge on 5/29/20. +// Copyright © 2020 AaronPrestidge. All rights reserved. +// + +import CoreData +import Foundation + +class StudentController { + + //MARK: - Shared Instance + static let shared = StudentController() + + //MARK: - Properties + var students: [Student] { + let request: NSFetchRequest = Student.fetchRequest() + let result = try? CoreDataStack.context.fetch(request) + print("Students array set") + return result ?? [] + } + + var pairs: [[Student]] = [] + + //MARK: - Helper Methods + func shuffle() { + var tempStudents: [Student] = [] + var tempPairs: [[Student]] = [] + for student in students.shuffled() { + if tempStudents.count < 2 { + tempStudents.append(student) + print("Student added to temporary array of students") + } else if tempStudents.count == 2 { + tempPairs.append(tempStudents) + print("Student pair added to temporary array of pairs") + tempStudents = [] + print("Temp student array emptied") + tempStudents.append(student) + print("Student added to temp students array") + } + } + if tempStudents.count > 0 { + tempPairs.append(tempStudents) + print("Student pair added to temporary array of pairs") + } + pairs = tempPairs + print("Pairs property set equal to tempPairs array.") + } + + //MARK: - CoreData Persistence + private func saveToPersistentStore() { + let mOC = CoreDataStack.context + do { + try mOC.save() + print("Data saved to CoreData") + } catch { + print("Error saving to CoreData: \(error.localizedDescription)") + } + } + + //MARK: - CRUD Functions + func create(from name: String) { + let _ = Student(name: name) + print("New student created") + saveToPersistentStore() + } + + func update(with student: Student, and name: String) { + student.name = name + print("Student has been updated") + saveToPersistentStore() + } + + func delete(student: Student) { + CoreDataStack.context.delete(student) + print("Student has been deleted") + saveToPersistentStore() + } + + +}//End Class diff --git a/Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift b/StudentPairs/StudentPairs/Controllers/ViewControllers/StudentDetailViewController.swift similarity index 50% rename from Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift rename to StudentPairs/StudentPairs/Controllers/ViewControllers/StudentDetailViewController.swift index 836e0fe..0c0be18 100644 --- a/Randomizer/Randomizer/Controllers/ViewControllers/StudentDetailViewController.swift +++ b/StudentPairs/StudentPairs/Controllers/ViewControllers/StudentDetailViewController.swift @@ -11,7 +11,11 @@ import UIKit class StudentDetailViewController: UIViewController { //MARK: - Properties - var student: Student? + var student: Student? { + didSet { + self.loadViewIfNeeded() + } + } //MARK: - Outlets @IBOutlet weak var nameTextField: UITextField! @@ -19,25 +23,28 @@ class StudentDetailViewController: UIViewController { //MARK: - Lifecycle override func viewDidLoad() { super.viewDidLoad() - + + if let student = student { + nameTextField.text = student.name + } } - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + nameTextField.becomeFirstResponder() } //MARK: - Actions @IBAction func saveButtonTapped(_ sender: UIButton) { - dismiss(animated: true) { - guard let name = self.nameTextField.text, - let student = self.student else { return } - StudentController.shared.update(student: student, name: name) - } + guard let name = self.nameTextField.text, + let student = self.student else { return } + StudentController.shared.update(with: student, and: name) + navigationController?.popViewController(animated: true) + } @IBAction func cancelButtonTapped(_ sender: UIBarButtonItem) { - dismiss(animated: true, completion: nil) + navigationController?.popViewController(animated: true) } - }//End Class diff --git a/Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift b/StudentPairs/StudentPairs/Controllers/ViewControllers/StudentsTableViewController.swift similarity index 60% rename from Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift rename to StudentPairs/StudentPairs/Controllers/ViewControllers/StudentsTableViewController.swift index 884b3da..e17efea 100644 --- a/Randomizer/Randomizer/Controllers/ViewControllers/StudentTableViewController.swift +++ b/StudentPairs/StudentPairs/Controllers/ViewControllers/StudentsTableViewController.swift @@ -1,15 +1,15 @@ // -// StudentTableViewController.swift -// Randomizer +// StudentsTableViewController.swift +// StudentPairs // -// Created by Aaron Prestidge on 5/28/20. +// Created by Aaron Prestidge on 5/29/20. // Copyright © 2020 AaronPrestidge. All rights reserved. // import UIKit -class StudentTableViewController: UITableViewController { - +class StudentsTableViewController: UITableViewController { + // MARK: - Lifecycle override func viewDidLoad() { super.viewDidLoad() @@ -17,6 +17,7 @@ class StudentTableViewController: UITableViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + StudentController.shared.shuffle() tableView.reloadData() } @@ -24,24 +25,38 @@ class StudentTableViewController: UITableViewController { @IBAction func addButtonTapped(_ sender: UIBarButtonItem) { presentAddStudentAlert() tableView.reloadData() + print("Add student alert controller presented, table view reloaded") } @IBAction func shuffleButtonTapped(_ sender: UIBarButtonItem) { - StudentController.shared.students.shuffle() + StudentController.shared.shuffle() tableView.reloadData() + print("Student pairs shuffled, table view reloaded") } - // MARK: - Table view data source - func indexOfCell(indexPath: IndexPath) -> Int { - return (indexPath.section * 2) + indexPath.row + // MARK: - Methods + func presentAddStudentAlert() { + let alertController = UIAlertController(title: "Add Student", message: "Add a new student to the list", preferredStyle: .alert) + var newStudentTextField: UITextField? + alertController.addTextField { (alertTextField) in + alertTextField.placeholder = "Enter name..." + newStudentTextField = alertTextField + } + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + let addAction = UIAlertAction(title: "Add", style: .default) { (_) in + guard let inputText = newStudentTextField?.text else { return } + StudentController.shared.create(from: inputText) + StudentController.shared.shuffle() + self.tableView.reloadData() + } + alertController.addAction(cancelAction) + alertController.addAction(addAction) + present(alertController, animated: true, completion: nil) } - + + // MARK: - Table view data source override func numberOfSections(in tableView: UITableView) -> Int { - if StudentController.shared.students.count % 2 == 0 { - return StudentController.shared.students.count / 2 - } else { - return (StudentController.shared.students.count / 2) + 1 - } + return StudentController.shared.pairs.count } override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { @@ -49,71 +64,62 @@ class StudentTableViewController: UITableViewController { } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if StudentController.shared.students.count % 2 == 0 { - return 2 - } else { - if section == (tableView.numberOfSections - 1) { - return 1 - } else { - return 2 - } - } + return StudentController.shared.pairs[section].count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "studentCell", for: indexPath) - let student = StudentController.shared.students[indexOfCell(indexPath: indexPath)] + let pair = StudentController.shared.pairs[indexPath.section] + let student = pair[indexPath.row] cell.textLabel?.text = student.name return cell } override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { if editingStyle == .delete { - let student = StudentController.shared.students[indexOfCell(indexPath: indexPath)] + let student = StudentController.shared.pairs[indexPath.section][indexPath.row] + StudentController.shared.pairs[indexPath.section].remove(at: indexPath.row) StudentController.shared.delete(student: student) tableView.deleteRows(at: [indexPath], with: .fade) + StudentController.shared.shuffle() tableView.reloadData() - } - } - - // MARK: - Methods - func presentAddStudentAlert() { - let alertController = UIAlertController(title: "Add Student", message: "Add a new student to the list", preferredStyle: .alert) - var newStudentTextField: UITextField? - alertController.addTextField { (alertTextField) in - alertTextField.placeholder = "Enter name..." - newStudentTextField = alertTextField - } - let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - let addAction = UIAlertAction(title: "Add", style: .default) { (_) in - guard let inputText = newStudentTextField?.text else { return } - StudentController.shared.create(name: inputText) - self.tableView.reloadData() } - alertController.addAction(cancelAction) - alertController.addAction(addAction) - present(alertController, animated: true, completion: nil) } - + // MARK: - Navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "toUpdateVC" { - guard let indexPath = tableView.indexPathForSelectedRow else { return } - let student = StudentController.shared.students[indexPath.row] - let updateVC = segue.destination as? StudentDetailViewController - updateVC?.student = student + guard let indexPath = tableView.indexPathForSelectedRow, + let destination = segue.destination as? StudentDetailViewController else { return } + destination.student = StudentController.shared.pairs[indexPath.section][indexPath.row] } } - }//End Class -extension Array { - mutating func shuffle() { - for _ in 0..<10 { - sort { - (_,_) in arc4random() < arc4random() - } +@IBDesignable extension UIButton { + @IBInspectable var borderWidth: CGFloat { + set { + layer.borderWidth = newValue + } get { + return layer.borderWidth + } + } + + @IBInspectable var cornerRadius: CGFloat { + set { + layer.cornerRadius = newValue } + get { + return layer.cornerRadius } + } + + @IBInspectable var borderColor: UIColor? { + set { + guard let uiColor = newValue else { return } + layer.borderColor = uiColor.cgColor + } get { + guard let color = layer.borderColor else { return nil } + return UIColor(cgColor: color) } } -} +}//End Extension diff --git a/Randomizer/Randomizer/Models/CoreDataStack.swift b/StudentPairs/StudentPairs/Models/CoreDataStack.swift similarity index 83% rename from Randomizer/Randomizer/Models/CoreDataStack.swift rename to StudentPairs/StudentPairs/Models/CoreDataStack.swift index 01afc17..a161b8c 100644 --- a/Randomizer/Randomizer/Models/CoreDataStack.swift +++ b/StudentPairs/StudentPairs/Models/CoreDataStack.swift @@ -1,8 +1,8 @@ // // CoreDataStack.swift -// Randomizer +// StudentPairs // -// Created by Aaron Prestidge on 5/28/20. +// Created by Aaron Prestidge on 5/29/20. // Copyright © 2020 AaronPrestidge. All rights reserved. // @@ -15,7 +15,7 @@ enum CoreDataStack { let appName = Bundle.main.object(forInfoDictionaryKey: (kCFBundleNameKey as String)) as! String let container = NSPersistentContainer(name: appName) - container.loadPersistentStores() { (storeDescription, error) in + container.loadPersistentStores() { (_, error) in if let error = error as NSError? { fatalError("Unresolved error \(error), \(error.userInfo)") } diff --git a/Randomizer/Randomizer/Models/Student+Convenience.swift b/StudentPairs/StudentPairs/Models/Student+Convenience.swift similarity index 85% rename from Randomizer/Randomizer/Models/Student+Convenience.swift rename to StudentPairs/StudentPairs/Models/Student+Convenience.swift index a314ac3..2e948ab 100644 --- a/Randomizer/Randomizer/Models/Student+Convenience.swift +++ b/StudentPairs/StudentPairs/Models/Student+Convenience.swift @@ -1,8 +1,8 @@ // // Student+Convenience.swift -// Randomizer +// StudentPairs // -// Created by Aaron Prestidge on 5/28/20. +// Created by Aaron Prestidge on 5/29/20. // Copyright © 2020 AaronPrestidge. All rights reserved. // diff --git a/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/.xccurrentversion b/StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/.xccurrentversion similarity index 83% rename from Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/.xccurrentversion rename to StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/.xccurrentversion index e1b06e3..703eaaf 100644 --- a/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/.xccurrentversion +++ b/StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - Randomizer.xcdatamodel + StudentPairs.xcdatamodel diff --git a/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents b/StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/StudentPairs.xcdatamodel/contents similarity index 84% rename from Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents rename to StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/StudentPairs.xcdatamodel/contents index 113cffb..40185a4 100644 --- a/Randomizer/Randomizer/Models/Randomizer.xcdatamodeld/Randomizer.xcdatamodel/contents +++ b/StudentPairs/StudentPairs/Models/StudentPairs.xcdatamodeld/StudentPairs.xcdatamodel/contents @@ -4,6 +4,6 @@ - + \ No newline at end of file diff --git a/Randomizer/Randomizer/Resources/AppDelegate.swift b/StudentPairs/StudentPairs/Resources/AppDelegate.swift similarity index 96% rename from Randomizer/Randomizer/Resources/AppDelegate.swift rename to StudentPairs/StudentPairs/Resources/AppDelegate.swift index 52c9115..0805dfd 100644 --- a/Randomizer/Randomizer/Resources/AppDelegate.swift +++ b/StudentPairs/StudentPairs/Resources/AppDelegate.swift @@ -1,8 +1,8 @@ // // AppDelegate.swift -// Randomizer +// StudentPairs // -// Created by Aaron Prestidge on 5/28/20. +// Created by Aaron Prestidge on 5/29/20. // Copyright © 2020 AaronPrestidge. All rights reserved. // @@ -42,7 +42,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { 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: "Randomizer") + let container = NSPersistentContainer(name: "StudentPairs") container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { // Replace this implementation with code to handle the error appropriately. diff --git a/Randomizer/Randomizer/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/StudentPairs/StudentPairs/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Randomizer/Randomizer/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json rename to StudentPairs/StudentPairs/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Randomizer/Randomizer/Resources/Assets.xcassets/Contents.json b/StudentPairs/StudentPairs/Resources/Assets.xcassets/Contents.json similarity index 100% rename from Randomizer/Randomizer/Resources/Assets.xcassets/Contents.json rename to StudentPairs/StudentPairs/Resources/Assets.xcassets/Contents.json diff --git a/Randomizer/Randomizer/Resources/Base.lproj/LaunchScreen.storyboard b/StudentPairs/StudentPairs/Resources/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Randomizer/Randomizer/Resources/Base.lproj/LaunchScreen.storyboard rename to StudentPairs/StudentPairs/Resources/Base.lproj/LaunchScreen.storyboard diff --git a/Randomizer/Randomizer/Resources/Info.plist b/StudentPairs/StudentPairs/Resources/Info.plist similarity index 85% rename from Randomizer/Randomizer/Resources/Info.plist rename to StudentPairs/StudentPairs/Resources/Info.plist index b5f9c07..e7f6f58 100644 --- a/Randomizer/Randomizer/Resources/Info.plist +++ b/StudentPairs/StudentPairs/Resources/Info.plist @@ -47,9 +47,21 @@ armv7 + UIStatusBarTintParameters + + UINavigationBar + + Style + UIBarStyleDefault + Translucent + + + UISupportedInterfaceOrientations UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad diff --git a/Randomizer/Randomizer/Resources/SceneDelegate.swift b/StudentPairs/StudentPairs/Resources/SceneDelegate.swift similarity index 99% rename from Randomizer/Randomizer/Resources/SceneDelegate.swift rename to StudentPairs/StudentPairs/Resources/SceneDelegate.swift index afdbb15..524f4f6 100644 --- a/Randomizer/Randomizer/Resources/SceneDelegate.swift +++ b/StudentPairs/StudentPairs/Resources/SceneDelegate.swift @@ -54,3 +54,4 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { } + \ No newline at end of file diff --git a/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard b/StudentPairs/StudentPairs/StoryboardViews/Base.lproj/Main.storyboard similarity index 52% rename from Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard rename to StudentPairs/StudentPairs/StoryboardViews/Base.lproj/Main.storyboard index c1413ed..e9310b3 100644 --- a/Randomizer/Randomizer/StoryboardViews/Base.lproj/Main.storyboard +++ b/StudentPairs/StudentPairs/StoryboardViews/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -7,91 +7,125 @@ - - + + - - + + + + + + + + + + + + + + + + + + + - - + + - + + + - + - - + + - - + + - + - + + - - + + - - + + + - + - + - + - + - - + + - + - @@ -99,45 +133,28 @@ - - - - + + + + - + - - + + + - + - + - - - - - - - - - - - - - - - - - - - + - +