diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b2ef06f Binary files /dev/null and b/.DS_Store differ diff --git a/JSON Encoding.xcodeproj/project.pbxproj b/JSON Encoding.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3cd84d6 --- /dev/null +++ b/JSON Encoding.xcodeproj/project.pbxproj @@ -0,0 +1,355 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 1C2CEAEF216FE058007A4192 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2CEAEE216FE058007A4192 /* AppDelegate.swift */; }; + 1C2CEAF1216FE058007A4192 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2CEAF0216FE058007A4192 /* ViewController.swift */; }; + 1C2CEAF4216FE058007A4192 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1C2CEAF2216FE058007A4192 /* Main.storyboard */; }; + 1C2CEAF6216FE05A007A4192 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1C2CEAF5216FE05A007A4192 /* Assets.xcassets */; }; + 1C2CEAF9216FE05A007A4192 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1C2CEAF7216FE05A007A4192 /* LaunchScreen.storyboard */; }; + 1C2CEB01216FE092007A4192 /* Student.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2CEB00216FE092007A4192 /* Student.swift */; }; + 1C2CEB03216FE922007A4192 /* StudentManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C2CEB02216FE922007A4192 /* StudentManager.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1C2CEAEB216FE058007A4192 /* JSON Encoding.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JSON Encoding.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 1C2CEAEE216FE058007A4192 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 1C2CEAF0216FE058007A4192 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 1C2CEAF3216FE058007A4192 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 1C2CEAF5216FE05A007A4192 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 1C2CEAF8216FE05A007A4192 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 1C2CEAFA216FE05A007A4192 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1C2CEB00216FE092007A4192 /* Student.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Student.swift; sourceTree = ""; }; + 1C2CEB02216FE922007A4192 /* StudentManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentManager.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1C2CEAE8216FE058007A4192 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1C2CEAE2216FE058007A4192 = { + isa = PBXGroup; + children = ( + 1C2CEAED216FE058007A4192 /* JSON Encoding */, + 1C2CEAEC216FE058007A4192 /* Products */, + ); + sourceTree = ""; + }; + 1C2CEAEC216FE058007A4192 /* Products */ = { + isa = PBXGroup; + children = ( + 1C2CEAEB216FE058007A4192 /* JSON Encoding.app */, + ); + name = Products; + sourceTree = ""; + }; + 1C2CEAED216FE058007A4192 /* JSON Encoding */ = { + isa = PBXGroup; + children = ( + 1C2CEAEE216FE058007A4192 /* AppDelegate.swift */, + 1C2CEAF0216FE058007A4192 /* ViewController.swift */, + 1C2CEAF2216FE058007A4192 /* Main.storyboard */, + 1C2CEAF5216FE05A007A4192 /* Assets.xcassets */, + 1C2CEAF7216FE05A007A4192 /* LaunchScreen.storyboard */, + 1C2CEAFA216FE05A007A4192 /* Info.plist */, + 1C2CEB04216FF7EF007A4192 /* Model */, + ); + path = "JSON Encoding"; + sourceTree = ""; + }; + 1C2CEB04216FF7EF007A4192 /* Model */ = { + isa = PBXGroup; + children = ( + 1C2CEB00216FE092007A4192 /* Student.swift */, + 1C2CEB02216FE922007A4192 /* StudentManager.swift */, + ); + path = Model; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1C2CEAEA216FE058007A4192 /* JSON Encoding */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1C2CEAFD216FE05A007A4192 /* Build configuration list for PBXNativeTarget "JSON Encoding" */; + buildPhases = ( + 1C2CEAE7216FE058007A4192 /* Sources */, + 1C2CEAE8216FE058007A4192 /* Frameworks */, + 1C2CEAE9216FE058007A4192 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "JSON Encoding"; + productName = "JSON Encoding"; + productReference = 1C2CEAEB216FE058007A4192 /* JSON Encoding.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1C2CEAE3216FE058007A4192 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1000; + LastUpgradeCheck = 1000; + ORGANIZATIONNAME = RNWolter; + TargetAttributes = { + 1C2CEAEA216FE058007A4192 = { + CreatedOnToolsVersion = 10.0; + }; + }; + }; + buildConfigurationList = 1C2CEAE6216FE058007A4192 /* Build configuration list for PBXProject "JSON Encoding" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 1C2CEAE2216FE058007A4192; + productRefGroup = 1C2CEAEC216FE058007A4192 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1C2CEAEA216FE058007A4192 /* JSON Encoding */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 1C2CEAE9216FE058007A4192 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1C2CEAF9216FE05A007A4192 /* LaunchScreen.storyboard in Resources */, + 1C2CEAF6216FE05A007A4192 /* Assets.xcassets in Resources */, + 1C2CEAF4216FE058007A4192 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1C2CEAE7216FE058007A4192 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1C2CEAF1216FE058007A4192 /* ViewController.swift in Sources */, + 1C2CEB03216FE922007A4192 /* StudentManager.swift in Sources */, + 1C2CEB01216FE092007A4192 /* Student.swift in Sources */, + 1C2CEAEF216FE058007A4192 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 1C2CEAF2216FE058007A4192 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1C2CEAF3216FE058007A4192 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 1C2CEAF7216FE05A007A4192 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1C2CEAF8216FE05A007A4192 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 1C2CEAFB216FE05A007A4192 /* 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; + }; + 1C2CEAFC216FE05A007A4192 /* 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; + }; + 1C2CEAFE216FE05A007A4192 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = "JSON Encoding/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.RNWolter.JSON-Encoding"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1C2CEAFF216FE05A007A4192 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = "JSON Encoding/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.RNWolter.JSON-Encoding"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1C2CEAE6216FE058007A4192 /* Build configuration list for PBXProject "JSON Encoding" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1C2CEAFB216FE05A007A4192 /* Debug */, + 1C2CEAFC216FE05A007A4192 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1C2CEAFD216FE05A007A4192 /* Build configuration list for PBXNativeTarget "JSON Encoding" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1C2CEAFE216FE05A007A4192 /* Debug */, + 1C2CEAFF216FE05A007A4192 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1C2CEAE3216FE058007A4192 /* Project object */; +} diff --git a/JSON Encoding.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/JSON Encoding.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..eb2a3d9 --- /dev/null +++ b/JSON Encoding.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/JSON Encoding.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/JSON Encoding.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/JSON Encoding.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/JSON Encoding.xcodeproj/project.xcworkspace/xcuserdata/RickWolter.xcuserdatad/UserInterfaceState.xcuserstate b/JSON Encoding.xcodeproj/project.xcworkspace/xcuserdata/RickWolter.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..f94e02a Binary files /dev/null and b/JSON Encoding.xcodeproj/project.xcworkspace/xcuserdata/RickWolter.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/JSON Encoding.xcodeproj/xcuserdata/RickWolter.xcuserdatad/xcschemes/xcschememanagement.plist b/JSON Encoding.xcodeproj/xcuserdata/RickWolter.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..9ddbe26 --- /dev/null +++ b/JSON Encoding.xcodeproj/xcuserdata/RickWolter.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + JSON Encoding.xcscheme + + orderHint + 0 + + + + diff --git a/JSON Encoding/AppDelegate.swift b/JSON Encoding/AppDelegate.swift new file mode 100644 index 0000000..901ec45 --- /dev/null +++ b/JSON Encoding/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// JSON Encoding +// +// Created by Rick Wolter on 10/11/18. +// Copyright © 2018 RNWolter. 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 Encoding/Assets.xcassets/AppIcon.appiconset/Contents.json b/JSON Encoding/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/JSON Encoding/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 Encoding/Assets.xcassets/Contents.json b/JSON Encoding/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/JSON Encoding/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/JSON Encoding/Base.lproj/LaunchScreen.storyboard b/JSON Encoding/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..bfa3612 --- /dev/null +++ b/JSON Encoding/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JSON Encoding/Base.lproj/Main.storyboard b/JSON Encoding/Base.lproj/Main.storyboard new file mode 100644 index 0000000..154ca4d --- /dev/null +++ b/JSON Encoding/Base.lproj/Main.storyboard @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JSON Encoding/Info.plist b/JSON Encoding/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/JSON Encoding/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 Encoding/Model/Student.swift b/JSON Encoding/Model/Student.swift new file mode 100644 index 0000000..e237cfb --- /dev/null +++ b/JSON Encoding/Model/Student.swift @@ -0,0 +1,41 @@ +// +// Student.swift +// JSON Encoding +// +// Created by Rick Wolter on 10/11/18. +// Copyright © 2018 RNWolter. All rights reserved. +// + +import Foundation + +struct Student: CustomStringConvertible, Codable { + + let name: String + let cohort: String? + let age: Int? +// +// init(name: String,cohort: String? = nil, age: Int){ +// self.name = name +// self.cohort = cohort +// self.age = age +// } + +// var description: String { +// let studentDescription = "\(name), Cohort: \(cohort ?? "unknown cohort"), \(age) years old" +// return studentDescription +// } + var description: String { + var studentDescription = name + + if let age = age { + studentDescription += ", aged " + String(age) + + } + + if let cohort = cohort { + studentDescription += ", cohort " + String(cohort) + } + return studentDescription + } + +} diff --git a/JSON Encoding/Model/StudentManager.swift b/JSON Encoding/Model/StudentManager.swift new file mode 100644 index 0000000..da43c7e --- /dev/null +++ b/JSON Encoding/Model/StudentManager.swift @@ -0,0 +1,45 @@ +// +// StudentManager.swift +// JSON Encoding +// +// Created by Rick Wolter on 10/11/18. +// Copyright © 2018 RNWolter. All rights reserved. +// + +import Foundation + +class StudentManager: NSObject { + + + var students = [Student]() + + + let url = URL(fileURLWithPath: NSHomeDirectory()) + .appendingPathComponent("Documents") + .appendingPathComponent("students.json") + + func writeToFile() { + + do { + let studentsEncoding = try JSONEncoder().encode(students) + try studentsEncoding.write(to: url) + } catch { + print("Error \(error)") + } + + + + } + + func readFromFile() { + do { + let studentData = try Data(contentsOf: url) + var studentsDecoded = try JSONDecoder().decode([Student].self, from: studentData) + students = studentsDecoded + + } catch { + print("Error: \(error)") + } + +} +} diff --git a/JSON Encoding/ViewController.swift b/JSON Encoding/ViewController.swift new file mode 100644 index 0000000..dfe9736 --- /dev/null +++ b/JSON Encoding/ViewController.swift @@ -0,0 +1,54 @@ +// +// ViewController.swift +// JSON Encoding +// +// Created by Rick Wolter on 10/11/18. +// Copyright © 2018 RNWolter. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + var studentManager = StudentManager() + + @IBOutlet weak var nameTextField: UITextField! + @IBOutlet weak var ageTextField: UITextField! + @IBOutlet weak var cohortTextField: UITextField! + + + override func viewWillAppear(_ animated: Bool) { + studentManager.readFromFile() + + } + override func viewDidLoad() { + super.viewDidLoad() + + } + + + + + @IBAction func printButton(_ sender: Any) { + + for i in studentManager.students { + print(i) + } + } + + @IBAction func save(_ sender: Any) { + guard let name = nameTextField.text, + let ageString = ageTextField.text, + let cohort = cohortTextField.text, + let age = Int(ageString) else {return} + + let student = Student(name: name, cohort: cohort, age: age) + studentManager.students.append(student) + studentManager.writeToFile() + + nameTextField.text = "" + ageTextField.text = "" + cohortTextField.text = "" + } +} +