diff --git a/ListApp/Controllers/ItemsController.swift b/ListApp/Controllers/ItemsController.swift new file mode 100644 index 0000000..35f9a20 --- /dev/null +++ b/ListApp/Controllers/ItemsController.swift @@ -0,0 +1,26 @@ +// +// ItemsController.swift +// ListApp +// +// Created by Nelson Gonzalez on 1/8/19. +// Copyright © 2019 Nelson Gonzalez. All rights reserved. +// + +import Foundation + +class ItemsController { + var items = [String]() + let bullets = "\u{2022}" + + func add(_ item: String) { + // add the item to your items list + items.append(bullets + " " + item) + + } + + func resetItems() { + items.removeAll() + } + + +} diff --git a/ListApp/Controllers/ViewController.swift b/ListApp/Controllers/ViewController.swift new file mode 100644 index 0000000..c667fe7 --- /dev/null +++ b/ListApp/Controllers/ViewController.swift @@ -0,0 +1,60 @@ +// +// ViewController.swift +// ListApp +// +// Created by Nelson Gonzalez on 1/8/19. +// Copyright © 2019 Nelson Gonzalez. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet weak var textField: UITextField! + + @IBOutlet weak var label: UILabel! + + + + var itemsController = ItemsController() + + + override func viewDidLoad() { + super.viewDidLoad() + + updateViews() + + } + + func updateViews(){ + label.text = nil + } + + + @IBAction func shouldAdd(_ sender: UIButton) { + + let text = textField.text ?? "" + + if !text.isEmpty { + itemsController.add(text) + textField.text = "" + } else { + print("No") + } + let joined = itemsController.items.joined(separator: "\n") + label.text = joined + + } + + @IBAction func shouldReset(_ sender: UIButton) { + itemsController.resetItems() + updateViews() + } + + @IBAction func printButton(_ sender: UIButton) { + + print(itemsController.items) + } + +} + diff --git a/ListApp/ListApp.xcodeproj/project.pbxproj b/ListApp/ListApp.xcodeproj/project.pbxproj new file mode 100644 index 0000000..461c80a --- /dev/null +++ b/ListApp/ListApp.xcodeproj/project.pbxproj @@ -0,0 +1,365 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 7A8ED50521E5374F00E9EE73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8ED50421E5374F00E9EE73 /* AppDelegate.swift */; }; + 7A8ED50721E5374F00E9EE73 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8ED50621E5374F00E9EE73 /* ViewController.swift */; }; + 7A8ED50A21E5374F00E9EE73 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A8ED50821E5374F00E9EE73 /* Main.storyboard */; }; + 7A8ED50C21E5375100E9EE73 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7A8ED50B21E5375100E9EE73 /* Assets.xcassets */; }; + 7A8ED50F21E5375100E9EE73 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A8ED50D21E5375100E9EE73 /* LaunchScreen.storyboard */; }; + 7A8ED51721E539E400E9EE73 /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8ED51621E539E400E9EE73 /* Item.swift */; }; + 7A8ED51B21E53A3300E9EE73 /* ItemsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8ED51A21E53A3300E9EE73 /* ItemsController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 7A8ED50121E5374F00E9EE73 /* ListApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ListApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 7A8ED50421E5374F00E9EE73 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7A8ED50621E5374F00E9EE73 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 7A8ED50921E5374F00E9EE73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 7A8ED50B21E5375100E9EE73 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 7A8ED50E21E5375100E9EE73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 7A8ED51021E5375100E9EE73 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7A8ED51621E539E400E9EE73 /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = ""; }; + 7A8ED51A21E53A3300E9EE73 /* ItemsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemsController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 7A8ED4FE21E5374F00E9EE73 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 7A8ED4F821E5374F00E9EE73 = { + isa = PBXGroup; + children = ( + 7A8ED51921E53A1A00E9EE73 /* Controllers */, + 7A8ED51821E539ED00E9EE73 /* Model */, + 7A8ED50321E5374F00E9EE73 /* ListApp */, + 7A8ED50221E5374F00E9EE73 /* Products */, + ); + sourceTree = ""; + }; + 7A8ED50221E5374F00E9EE73 /* Products */ = { + isa = PBXGroup; + children = ( + 7A8ED50121E5374F00E9EE73 /* ListApp.app */, + ); + name = Products; + sourceTree = ""; + }; + 7A8ED50321E5374F00E9EE73 /* ListApp */ = { + isa = PBXGroup; + children = ( + 7A8ED50421E5374F00E9EE73 /* AppDelegate.swift */, + 7A8ED50821E5374F00E9EE73 /* Main.storyboard */, + 7A8ED50B21E5375100E9EE73 /* Assets.xcassets */, + 7A8ED50D21E5375100E9EE73 /* LaunchScreen.storyboard */, + 7A8ED51021E5375100E9EE73 /* Info.plist */, + ); + path = ListApp; + sourceTree = ""; + }; + 7A8ED51821E539ED00E9EE73 /* Model */ = { + isa = PBXGroup; + children = ( + 7A8ED51621E539E400E9EE73 /* Item.swift */, + ); + path = Model; + sourceTree = ""; + }; + 7A8ED51921E53A1A00E9EE73 /* Controllers */ = { + isa = PBXGroup; + children = ( + 7A8ED51A21E53A3300E9EE73 /* ItemsController.swift */, + 7A8ED50621E5374F00E9EE73 /* ViewController.swift */, + ); + path = Controllers; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 7A8ED50021E5374F00E9EE73 /* ListApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 7A8ED51321E5375100E9EE73 /* Build configuration list for PBXNativeTarget "ListApp" */; + buildPhases = ( + 7A8ED4FD21E5374F00E9EE73 /* Sources */, + 7A8ED4FE21E5374F00E9EE73 /* Frameworks */, + 7A8ED4FF21E5374F00E9EE73 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ListApp; + productName = ListApp; + productReference = 7A8ED50121E5374F00E9EE73 /* ListApp.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 7A8ED4F921E5374F00E9EE73 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1010; + LastUpgradeCheck = 1010; + ORGANIZATIONNAME = "Nelson Gonzalez"; + TargetAttributes = { + 7A8ED50021E5374F00E9EE73 = { + CreatedOnToolsVersion = 10.1; + }; + }; + }; + buildConfigurationList = 7A8ED4FC21E5374F00E9EE73 /* Build configuration list for PBXProject "ListApp" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 7A8ED4F821E5374F00E9EE73; + productRefGroup = 7A8ED50221E5374F00E9EE73 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 7A8ED50021E5374F00E9EE73 /* ListApp */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 7A8ED4FF21E5374F00E9EE73 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7A8ED50F21E5375100E9EE73 /* LaunchScreen.storyboard in Resources */, + 7A8ED50C21E5375100E9EE73 /* Assets.xcassets in Resources */, + 7A8ED50A21E5374F00E9EE73 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 7A8ED4FD21E5374F00E9EE73 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7A8ED50721E5374F00E9EE73 /* ViewController.swift in Sources */, + 7A8ED51721E539E400E9EE73 /* Item.swift in Sources */, + 7A8ED51B21E53A3300E9EE73 /* ItemsController.swift in Sources */, + 7A8ED50521E5374F00E9EE73 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 7A8ED50821E5374F00E9EE73 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 7A8ED50921E5374F00E9EE73 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 7A8ED50D21E5375100E9EE73 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 7A8ED50E21E5375100E9EE73 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 7A8ED51121E5375100E9EE73 /* 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.1; + 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; + }; + 7A8ED51221E5375100E9EE73 /* 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.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 7A8ED51421E5375100E9EE73 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ZD9LN99SX6; + INFOPLIST_FILE = ListApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.nelsongonzalez.ListApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 7A8ED51521E5375100E9EE73 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ZD9LN99SX6; + INFOPLIST_FILE = ListApp/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.nelsongonzalez.ListApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 7A8ED4FC21E5374F00E9EE73 /* Build configuration list for PBXProject "ListApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7A8ED51121E5375100E9EE73 /* Debug */, + 7A8ED51221E5375100E9EE73 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 7A8ED51321E5375100E9EE73 /* Build configuration list for PBXNativeTarget "ListApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7A8ED51421E5375100E9EE73 /* Debug */, + 7A8ED51521E5375100E9EE73 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 7A8ED4F921E5374F00E9EE73 /* Project object */; +} diff --git a/ListApp/ListApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ListApp/ListApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9cf01a3 --- /dev/null +++ b/ListApp/ListApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ListApp/ListApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ListApp/ListApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ListApp/ListApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ListApp/ListApp/AppDelegate.swift b/ListApp/ListApp/AppDelegate.swift new file mode 100644 index 0000000..b73458d --- /dev/null +++ b/ListApp/ListApp/AppDelegate.swift @@ -0,0 +1,26 @@ +// +// AppDelegate.swift +// ListApp +// +// Created by Nelson Gonzalez on 1/8/19. +// Copyright © 2019 Nelson Gonzalez. 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 + } + + + + +} + diff --git a/ListApp/ListApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/ListApp/ListApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/ListApp/ListApp/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/ListApp/ListApp/Assets.xcassets/Contents.json b/ListApp/ListApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/ListApp/ListApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ListApp/ListApp/Base.lproj/LaunchScreen.storyboard b/ListApp/ListApp/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..bfa3612 --- /dev/null +++ b/ListApp/ListApp/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ListApp/ListApp/Base.lproj/Main.storyboard b/ListApp/ListApp/Base.lproj/Main.storyboard new file mode 100644 index 0000000..1f01318 --- /dev/null +++ b/ListApp/ListApp/Base.lproj/Main.storyboard @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ListApp/ListApp/Info.plist b/ListApp/ListApp/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/ListApp/ListApp/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/ListApp/Model/Item.swift b/ListApp/Model/Item.swift new file mode 100644 index 0000000..ba10273 --- /dev/null +++ b/ListApp/Model/Item.swift @@ -0,0 +1,13 @@ +// +// Item.swift +// ListApp +// +// Created by Nelson Gonzalez on 1/8/19. +// Copyright © 2019 Nelson Gonzalez. All rights reserved. +// + +import Foundation + +struct Item { + var name: String +} diff --git a/README.md b/README.md index 47a9655..574359a 100644 --- a/README.md +++ b/README.md @@ -1,125 +1,16 @@ -# Module Challenge: View Controllers and the Model-View-Controller Design Pattern - List - -This challenge allows you to practice the concepts and techniques learned in today's guided lesson and apply them in a concrete project. Your lesson explored the view controller, IB's object library, and Model-View-Controller. You will demonstrate proficiency by creating an application that showcases the same features you learned in class. - -## Instructions - -**Read these instructions carefully. Understand exactly what is expected _before_ starting this Challenge.** - -This is an individual assessment but you are permitted to consult with and support other members of your cohort. You are encouraged to follow the twenty-minute rule and seek support from your PM and Instructor in your cohort help channel on Slack. - -## Commits - -Commit your code regularly and meaningfully. This helps both you (in case you ever need to return to old code for any number of reasons) and your project manager. - -## Description - -In this challenge, you build a list of items. These items can be anything you need to keep track of: things to do, things to buy, or a list of your children or pets. - -Your completed application will look like the following GIF: - -![](Images/Finished.gif) ## Questions Demonstrate your understanding of today's concepts by answering the following free-form questions. Submit them as a text file along with your project. * What is Interface Builder's object library? +It is the library of objects that you can use to build your app. Includes things like viewControllers, labels, buttons, images, and a lot more.. * What is the difference between an outlet and an action? +An outlet is like a reference from your label for example to the code. So that it works with your code. An action is a function that performs an operation when it is clicked on a button for example * What is the role of a View Controller? +A view controllers role is to have the code to run which include references to objects, views, and model * What is Model-View-Controller? +It is a way to organize code and make it easy to update, modify and changed in a simpler way. The controller can access the model and do CRUD operations and the controller also tells the view what the things on the view will do. * Why use Model-View-Controller? +It is a way to organize code and make it easy to update, modify and changed in a simpler way. - -## Project Setup - -Follow these steps to set up your project: - -- Create a new Single View application. Clean up the boilerplate in the application delegate and custom View Controller class. -- Add a new Item.swift file to your project with the following contents: - -``` -struct Item { - var name: String -} -``` - -- Create a model controller by creating a new file, ItemsController.swift: - -``` -class ItemsController { - var items: [String] = [] -} -``` - -## Building your Model - -- Add a method to add a new item to your list. You must complete this method so it adds a new item. - -``` -func add(_ item: String) { - // add the item to your items list -} -``` - -- Add a method that resets your list. You must complete this method too. - -``` -func resetItems() { - // reset your items list here -} -``` - -## Building your Interface - -Follow these steps in IB to lay out your interface - -- Drag a button and a text field into interface builder, with the button to the right. Embed these items into a stack view. -- Use the attributes inspector to set the stack view spacing to 8. -- Drag in a label and another button. Make a vertical stack including your first label/button stack, then the label, then the other button. -- Use the attributes inspector to set the stack view spacing to 8 and the alignment to Fill. -- With the stack view still selected, use the Tie Fighter to set offsets to 8 above, to the left, to the right, and below. Add all four constraints. -- Select the label from the document overview. In the attributes inspector, set the number of lines from 1 to 0. -- Select the bottom button from the document overview. Open the size inspector (View > Inspectors > Show Size Inspector). Locate the vertical content hugging priority. Set it to 1000. -- Select the other button at the top and repeat. Then set the horizontal hugging priority and set it to 750. -- Select the top button and double-click it or use the attributes inspector to change its name to Add. -- Select the bottom button and double-click it or use the attributes inspector to change its name to Reset. - -Your interface should now look like this: - -![](Images/IBPreview.png) - -To finish: - -- Edit the label text so there's no text there by default. -- Select the text field and use the Attributes Inspector to set its placeholder to "New item..." - -## Connecting Your Interface - -Follow these steps to hook up your interface to your ViewController implementation. - -- With Interface Builder open, option-click ViewController.swift to open it in an assistant editor. -- Control-drag to add outlets for your text field (`textField`) and label (`label`). -- Control-drag to add actions for your "Add" (`shouldAdd`) and "Reset" (`shouldReset`) buttons. -- Implement shouldReset by calling your model's `resetItems()` method and then set the label text to `""`. -- In `shouldAdd`, use nil-coalescing to retrieve text from the text field: `let text = textField.text ?? ""`. -- If the text is not empty (`!text.isEmpty`), add it to your model. Then set the textField text to `""`. (Why do you do this? Try to think it through and test it both ways.) -- Use a `joined` method to convert your model's list to a string: `let joined = Model.shared.items.joined(separator: "\n")` - -## Minimum Viable Product - -Your finished project must include all of the following requirements: - -* You can add items to your list -* You can reset your list -* You will not add empty items to your list -* Your add field automatically clears after adding an item -* Your project looks, feels, and acts like the example shown above. - -## Stretch Problems - -After finishing your required elements, push your work further. These goals may or may not be things you learned in this module but they build on the material you just studied. Time allowing, stretch your limits and see if you can deliver on the following optional goals: - -- Add a second button at the bottom that prints out your list to the debugging console using `print` statements. -- Add bullets to each item in your list. -- Replace the text field in your project with a non-editable text view so your list can be top-aligned.