diff --git a/JSON Students/JSON Students.xcodeproj/project.pbxproj b/JSON Students/JSON Students.xcodeproj/project.pbxproj new file mode 100644 index 0000000..0b756ce --- /dev/null +++ b/JSON Students/JSON Students.xcodeproj/project.pbxproj @@ -0,0 +1,349 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 47F6BED9216FDC9E007A370E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F6BED8216FDC9E007A370E /* AppDelegate.swift */; }; + 47F6BEDB216FDC9E007A370E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F6BEDA216FDC9E007A370E /* ViewController.swift */; }; + 47F6BEDE216FDC9E007A370E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 47F6BEDC216FDC9E007A370E /* Main.storyboard */; }; + 47F6BEE0216FDC9F007A370E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 47F6BEDF216FDC9F007A370E /* Assets.xcassets */; }; + 47F6BEE3216FDC9F007A370E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 47F6BEE1216FDC9F007A370E /* LaunchScreen.storyboard */; }; + 47F6BEEB216FDCCC007A370E /* Student.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F6BEEA216FDCCC007A370E /* Student.swift */; }; + 47F6BEED216FDE15007A370E /* StudentManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F6BEEC216FDE15007A370E /* StudentManager.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 47F6BED5216FDC9E007A370E /* JSON Students.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JSON Students.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 47F6BED8216FDC9E007A370E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 47F6BEDA216FDC9E007A370E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 47F6BEDD216FDC9E007A370E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 47F6BEDF216FDC9F007A370E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 47F6BEE2216FDC9F007A370E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 47F6BEE4216FDC9F007A370E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 47F6BEEA216FDCCC007A370E /* Student.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Student.swift; sourceTree = ""; }; + 47F6BEEC216FDE15007A370E /* StudentManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentManager.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 47F6BED2216FDC9E007A370E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 47F6BECC216FDC9E007A370E = { + isa = PBXGroup; + children = ( + 47F6BED7216FDC9E007A370E /* JSON Students */, + 47F6BED6216FDC9E007A370E /* Products */, + ); + sourceTree = ""; + }; + 47F6BED6216FDC9E007A370E /* Products */ = { + isa = PBXGroup; + children = ( + 47F6BED5216FDC9E007A370E /* JSON Students.app */, + ); + name = Products; + sourceTree = ""; + }; + 47F6BED7216FDC9E007A370E /* JSON Students */ = { + isa = PBXGroup; + children = ( + 47F6BED8216FDC9E007A370E /* AppDelegate.swift */, + 47F6BEDA216FDC9E007A370E /* ViewController.swift */, + 47F6BEDC216FDC9E007A370E /* Main.storyboard */, + 47F6BEEA216FDCCC007A370E /* Student.swift */, + 47F6BEEC216FDE15007A370E /* StudentManager.swift */, + 47F6BEDF216FDC9F007A370E /* Assets.xcassets */, + 47F6BEE1216FDC9F007A370E /* LaunchScreen.storyboard */, + 47F6BEE4216FDC9F007A370E /* Info.plist */, + ); + path = "JSON Students"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 47F6BED4216FDC9E007A370E /* JSON Students */ = { + isa = PBXNativeTarget; + buildConfigurationList = 47F6BEE7216FDC9F007A370E /* Build configuration list for PBXNativeTarget "JSON Students" */; + buildPhases = ( + 47F6BED1216FDC9E007A370E /* Sources */, + 47F6BED2216FDC9E007A370E /* Frameworks */, + 47F6BED3216FDC9E007A370E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "JSON Students"; + productName = "JSON Students"; + productReference = 47F6BED5216FDC9E007A370E /* JSON Students.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 47F6BECD216FDC9E007A370E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1000; + LastUpgradeCheck = 1000; + ORGANIZATIONNAME = "Jerrick Warren"; + TargetAttributes = { + 47F6BED4216FDC9E007A370E = { + CreatedOnToolsVersion = 10.0; + }; + }; + }; + buildConfigurationList = 47F6BED0216FDC9E007A370E /* Build configuration list for PBXProject "JSON Students" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 47F6BECC216FDC9E007A370E; + productRefGroup = 47F6BED6216FDC9E007A370E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 47F6BED4216FDC9E007A370E /* JSON Students */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 47F6BED3216FDC9E007A370E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 47F6BEE3216FDC9F007A370E /* LaunchScreen.storyboard in Resources */, + 47F6BEE0216FDC9F007A370E /* Assets.xcassets in Resources */, + 47F6BEDE216FDC9E007A370E /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 47F6BED1216FDC9E007A370E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 47F6BEDB216FDC9E007A370E /* ViewController.swift in Sources */, + 47F6BEED216FDE15007A370E /* StudentManager.swift in Sources */, + 47F6BEEB216FDCCC007A370E /* Student.swift in Sources */, + 47F6BED9216FDC9E007A370E /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 47F6BEDC216FDC9E007A370E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 47F6BEDD216FDC9E007A370E /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 47F6BEE1216FDC9F007A370E /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 47F6BEE2216FDC9F007A370E /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 47F6BEE5216FDC9F007A370E /* 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; + CODE_SIGN_IDENTITY = "iPhone Developer"; + 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 = 12.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 47F6BEE6216FDC9F007A370E /* 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; + CODE_SIGN_IDENTITY = "iPhone Developer"; + 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 = 12.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 47F6BEE8216FDC9F007A370E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 7JG93VFG2G; + INFOPLIST_FILE = "JSON Students/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.jerrickwarren.JSON-Students"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 47F6BEE9216FDC9F007A370E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 7JG93VFG2G; + INFOPLIST_FILE = "JSON Students/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.jerrickwarren.JSON-Students"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 47F6BED0216FDC9E007A370E /* Build configuration list for PBXProject "JSON Students" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 47F6BEE5216FDC9F007A370E /* Debug */, + 47F6BEE6216FDC9F007A370E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 47F6BEE7216FDC9F007A370E /* Build configuration list for PBXNativeTarget "JSON Students" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 47F6BEE8216FDC9F007A370E /* Debug */, + 47F6BEE9216FDC9F007A370E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 47F6BECD216FDC9E007A370E /* Project object */; +} diff --git a/JSON Students/JSON Students.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/JSON Students/JSON Students.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b4d493a --- /dev/null +++ b/JSON Students/JSON Students.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/JSON Students/JSON Students.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/JSON Students/JSON Students.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/JSON Students/JSON Students.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/JSON Students/JSON Students.xcodeproj/project.xcworkspace/xcuserdata/jerrickwarren.xcuserdatad/UserInterfaceState.xcuserstate b/JSON Students/JSON Students.xcodeproj/project.xcworkspace/xcuserdata/jerrickwarren.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..79eef74 Binary files /dev/null and b/JSON Students/JSON Students.xcodeproj/project.xcworkspace/xcuserdata/jerrickwarren.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/JSON Students/JSON Students.xcodeproj/xcuserdata/jerrickwarren.xcuserdatad/xcschemes/xcschememanagement.plist b/JSON Students/JSON Students.xcodeproj/xcuserdata/jerrickwarren.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..5028ac4 --- /dev/null +++ b/JSON Students/JSON Students.xcodeproj/xcuserdata/jerrickwarren.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + JSON Students.xcscheme + + orderHint + 0 + + + + diff --git a/JSON Students/JSON Students/AppDelegate.swift b/JSON Students/JSON Students/AppDelegate.swift new file mode 100644 index 0000000..e394216 --- /dev/null +++ b/JSON Students/JSON Students/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// JSON Students +// +// Created by Jerrick Warren on 10/11/18. +// Copyright © 2018 Jerrick Warren. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/JSON Students/JSON Students/Assets.xcassets/AppIcon.appiconset/Contents.json b/JSON Students/JSON Students/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/JSON Students/JSON Students/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/JSON Students/JSON Students/Assets.xcassets/Contents.json b/JSON Students/JSON Students/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/JSON Students/JSON Students/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/JSON Students/JSON Students/Base.lproj/LaunchScreen.storyboard b/JSON Students/JSON Students/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..bfa3612 --- /dev/null +++ b/JSON Students/JSON Students/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JSON Students/JSON Students/Base.lproj/Main.storyboard b/JSON Students/JSON Students/Base.lproj/Main.storyboard new file mode 100644 index 0000000..1b30290 --- /dev/null +++ b/JSON Students/JSON Students/Base.lproj/Main.storyboard @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JSON Students/JSON Students/Info.plist b/JSON Students/JSON Students/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/JSON Students/JSON Students/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/JSON Students/JSON Students/Student.swift b/JSON Students/JSON Students/Student.swift new file mode 100644 index 0000000..4897ae1 --- /dev/null +++ b/JSON Students/JSON Students/Student.swift @@ -0,0 +1,33 @@ +// +// Student.swift +// JSON Students +// +// Created by Jerrick Warren on 10/11/18. +// Copyright © 2018 Jerrick Warren. All rights reserved. +// + +import Foundation + +struct Student: CustomStringConvertible, Codable { + // lets conform to the CSC protocol + // lets also do a computed property + var description: String { + // return "\(name), \(age), \(cohort)" + // optional colescing + var result = "\(name), Cohort: \(cohort ?? "[unknown cohort]")" + + // unwrapping the age + if let age = age { + result += ", \(age) Moons old" + } + return result + } + + let name: String + let age: Int? + let cohort: String? + + init(name: String, age: Int? = nil , cohort: String? = nil ) { + (self.name, self.age, self.cohort) = (name, age, cohort) + } +} diff --git a/JSON Students/JSON Students/StudentManager.swift b/JSON Students/JSON Students/StudentManager.swift new file mode 100644 index 0000000..2bc9555 --- /dev/null +++ b/JSON Students/JSON Students/StudentManager.swift @@ -0,0 +1,56 @@ +// +// StudentManager.swift +// JSON Students +// +// Created by Jerrick Warren on 10/11/18. +// Copyright © 2018 Jerrick Warren. All rights reserved. +// + +import Foundation + +class StudentManager: NSObject { + + var students: [Student] = [] + + let url = URL(fileURLWithPath: NSHomeDirectory()) + .appendingPathComponent("Documents") + .appendingPathComponent("students.json") + + func writeToFile() { + + // JSON Encoder + // JSON write to file? + // do - catch + + do { + let studentsEncoded = try JSONEncoder().encode(students) + try studentsEncoded.write(to: url) +// if let string = String(data: studentsEncoded, encoding: .utf8) { +// print(string) +// } + }catch { + print("Error: \(error)") + } + } + + func readFromFile() { + + // JSON DeCoder + // JSON read from file? + // do - catch + + do { + let data = try Data(contentsOf: url) + let studentsDecoded = try JSONDecoder().decode([Student].self, from: data) + students = studentsDecoded + } catch { + print("Error: \(error)") + } + } + + func create(name: String, age: Int?, cohort: String?) { + let student = Student.init(name: name , age: age, cohort: cohort) + students.append(student) + + } +} diff --git a/JSON Students/JSON Students/ViewController.swift b/JSON Students/JSON Students/ViewController.swift new file mode 100644 index 0000000..53d4ad8 --- /dev/null +++ b/JSON Students/JSON Students/ViewController.swift @@ -0,0 +1,43 @@ +// +// ViewController.swift +// JSON Students +// +// Created by Jerrick Warren on 10/11/18. +// Copyright © 2018 Jerrick Warren. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + let studentManager = StudentManager() + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + studentManager.readFromFile() + } + + @IBOutlet weak var nameTextField: UITextField! + @IBOutlet weak var ageTextField: UITextField! + @IBOutlet weak var cohortTextField: UITextField! + + @IBAction func saveButton(_ sender: Any) { + guard let name = nameTextField.text, + let age = ageTextField.text, + let cohort = cohortTextField.text else {return} + studentManager.create(name: name, age: Int(age), cohort: cohort) + studentManager.writeToFile() + + } + + @IBAction func printButton(_ sender: Any) { + print(studentManager.students) + } + +} +