From ab044457819f66db49ceec10001116213a3c0993 Mon Sep 17 00:00:00 2001 From: Richard Critz Date: Sat, 9 Jan 2021 23:46:48 -0500 Subject: [PATCH] Style Guide compliance --- .../App/Controllers/UsersController.swift | 1 - .../App/Controllers/WebsiteController.swift | 5 ++--- .../Tests/AppTests/Application+Testable.swift | 6 +++--- .../TILiOS/TILiOS.xcodeproj/project.pbxproj | 13 ++++++------ .../TILiOS/Project Files/AppDelegate.swift | 2 +- .../TILiOS/TILiOS/Project Files/Info.plist | 10 +++++----- .../Project Files/LaunchScreen.storyboard | 20 +++++++++---------- .../TILiOS/Utilities/AcronymRequest.swift | 5 ++++- .../final/TILiOS/TILiOS/Utilities/Auth.swift | 2 +- .../TILiOS/Utilities/ResourceRequest.swift | 5 ++++- .../AcronymsTableViewController.swift | 2 +- .../CreateAcronymTableViewController.swift | 10 ++++++++-- .../CreateCategoryTableViewController.swift | 8 ++++---- .../CreateUserTableViewController.swift | 15 +++++++++++--- .../LoginTableViewController.swift | 10 ++++++++-- .../App/Controllers/UsersController.swift | 1 - .../App/Controllers/WebsiteController.swift | 5 ++--- .../TILApp/Tests/AppTests/AcronymTests.swift | 1 - .../TILiOS/TILiOS.xcodeproj/project.pbxproj | 13 ++++++------ .../TILiOS/Project Files/AppDelegate.swift | 2 +- .../TILiOS/TILiOS/Project Files/Info.plist | 10 +++++----- .../Project Files/LaunchScreen.storyboard | 20 +++++++++---------- .../TILiOS/Utilities/AcronymRequest.swift | 12 +++++------ .../AcronymsTableViewController.swift | 2 +- .../CreateAcronymTableViewController.swift | 10 ++++++++-- .../CreateCategoryTableViewController.swift | 8 ++++---- .../CreateUserTableViewController.swift | 15 +++++++++++--- .../LoginTableViewController.swift | 10 ++++++++-- 28 files changed, 132 insertions(+), 91 deletions(-) diff --git a/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/UsersController.swift b/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/UsersController.swift index ce09927..664b700 100644 --- a/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/UsersController.swift +++ b/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/UsersController.swift @@ -29,7 +29,6 @@ import Vapor struct UsersController: RouteCollection { - func boot(routes: RoutesBuilder) throws { let usersRoute = routes.grouped("api", "users") usersRoute.get(use: getAllHandler) diff --git a/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/WebsiteController.swift b/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/WebsiteController.swift index 0c62578..f982ad9 100644 --- a/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/WebsiteController.swift +++ b/19-basic-authentication-part2/projects/final/TILApp/Sources/App/Controllers/WebsiteController.swift @@ -29,7 +29,6 @@ import Vapor struct WebsiteController: RouteCollection { - func boot(routes: RoutesBuilder) throws { routes.get(use: indexHandler) routes.get("acronyms", ":acronymID", use: acronymHandler) @@ -114,7 +113,7 @@ struct WebsiteController: RouteCollection { guard let id = acronym.id else { return req.eventLoop.future(error: Abort(.internalServerError)) } - var categorySaves = [EventLoopFuture]() + var categorySaves: [EventLoopFuture] = [] for category in data.categories ?? [] { categorySaves.append(Category.addCategory(category, to: acronym, on: req)) } @@ -156,7 +155,7 @@ struct WebsiteController: RouteCollection { let categoriesToAdd = newSet.subtracting(existingSet) let categoriesToRemove = existingSet.subtracting(newSet) - var categoryResults = [EventLoopFuture]() + var categoryResults: [EventLoopFuture] = [] for newCategory in categoriesToAdd { categoryResults.append(Category.addCategory(newCategory, to: acronym, on: req)) } diff --git a/19-basic-authentication-part2/projects/final/TILApp/Tests/AppTests/Application+Testable.swift b/19-basic-authentication-part2/projects/final/TILApp/Tests/AppTests/Application+Testable.swift index 157693d..8ad6ce0 100644 --- a/19-basic-authentication-part2/projects/final/TILApp/Tests/AppTests/Application+Testable.swift +++ b/19-basic-authentication-part2/projects/final/TILApp/Tests/AppTests/Application+Testable.swift @@ -52,7 +52,7 @@ extension XCTApplicationTester { body: ByteBufferAllocator().buffer(capacity: 0) ) request.headers.basicAuthorization = .init(username: user.username, password: "password") - let response = try self.performTest(request: request) + let response = try performTest(request: request) return try response.content.decode(Token.self) } @@ -85,14 +85,14 @@ extension XCTApplicationTester { userToLogin = User(name: "Admin", username: "admin", password: "password") } - let token = try self.login(user: userToLogin) + let token = try login(user: userToLogin) request.headers.bearerAuthorization = .init(token: token.value) } try beforeRequest(&request) do { - let response = try self.performTest(request: request) + let response = try performTest(request: request) try afterResponse(response) } catch { XCTFail("\(error)", file: (file), line: line) diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS.xcodeproj/project.pbxproj b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS.xcodeproj/project.pbxproj index 9e5cfb0..f581510 100755 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS.xcodeproj/project.pbxproj +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS.xcodeproj/project.pbxproj @@ -171,7 +171,7 @@ isa = PBXNativeTarget; buildConfigurationList = D2A5F2121F4A9144005CD714 /* Build configuration list for PBXNativeTarget "TILiOS" */; buildPhases = ( - 2323AF6D24B7811400D2E1B6 /* ShellScript */, + 2323AF6D24B7811400D2E1B6 /* SwiftLint */, D2A5F1FC1F4A9144005CD714 /* Sources */, D2A5F1FD1F4A9144005CD714 /* Frameworks */, D2A5F1FE1F4A9144005CD714 /* Resources */, @@ -193,7 +193,7 @@ attributes = { LastSwiftUpdateCheck = 0900; LastUpgradeCheck = 1230; - ORGANIZATIONNAME = Razeware; + ORGANIZATIONNAME = "Ray Wenderlich"; TargetAttributes = { D2A5F1FF1F4A9144005CD714 = { CreatedOnToolsVersion = 9.0; @@ -234,7 +234,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 2323AF6D24B7811400D2E1B6 /* ShellScript */ = { + 2323AF6D24B7811400D2E1B6 /* SwiftLint */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -243,13 +243,14 @@ ); inputPaths = ( ); + name = SwiftLint; outputFileListPaths = ( ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -f ~/com.raywenderlich.swiftlint.yml ]; then\n if which swiftlint >/dev/null; then\n swiftlint --config ~/com.raywenderlich.swiftlint.yml\n fi\nfi\n"; + shellScript = "if [ -f ~/com.raywenderlich.swiftlint.yml ]; then\n if which swiftlint >/dev/null; then\n swiftlint --no-cache --config ~/com.raywenderlich.swiftlint.yml\n fi\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -421,7 +422,7 @@ DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/TILiOS/Project Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.razeware.TILiOS; + PRODUCT_BUNDLE_IDENTIFIER = com.raywenderlich.TILiOS; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = 1; @@ -436,7 +437,7 @@ DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/TILiOS/Project Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.razeware.TILiOS; + PRODUCT_BUNDLE_IDENTIFIER = com.raywenderlich.TILiOS; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 1; }; diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/AppDelegate.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/AppDelegate.swift index 5c1bc7b..8b80fe5 100755 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/AppDelegate.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/AppDelegate.swift @@ -36,7 +36,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if Auth().token == nil { let rootController = UIStoryboard(name: "Login", bundle: Bundle.main) .instantiateViewController(withIdentifier: "LoginNavigation") - self.window?.rootViewController = rootController + window?.rootViewController = rootController } return true } diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/Info.plist b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/Info.plist index 2feba9d..f87da23 100755 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/Info.plist +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/Info.plist @@ -20,6 +20,11 @@ 1 LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -34,11 +39,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard index 4e46496..15d3c0b 100755 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard @@ -1,11 +1,9 @@ - - - - + + - - + + @@ -15,26 +13,27 @@ - + - + - + + - + @@ -42,7 +41,6 @@ - diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/AcronymRequest.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/AcronymRequest.swift index 63b8bbf..aa7db31 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/AcronymRequest.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/AcronymRequest.swift @@ -97,7 +97,10 @@ struct AcronymRequest { completion(.failure(.noData)) return } - guard httpResponse.statusCode == 200, let jsonData = data else { + guard + httpResponse.statusCode == 200, + let jsonData = data + else { if httpResponse.statusCode == 401 { Auth().logout() } diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/Auth.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/Auth.swift index 306379f..f64b89d 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/Auth.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/Auth.swift @@ -49,7 +49,7 @@ class Auth { } func logout() { - self.token = nil + token = nil DispatchQueue.main.async { guard let applicationDelegate = UIApplication.shared.delegate as? AppDelegate else { diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/ResourceRequest.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/ResourceRequest.swift index ce235eb..7907667 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/ResourceRequest.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/Utilities/ResourceRequest.swift @@ -75,7 +75,10 @@ struct ResourceRequest where ResourceType: Codable { completion(.failure(.noData)) return } - guard httpResponse.statusCode == 200, let jsonData = data else { + guard + httpResponse.statusCode == 200, + let jsonData = data + else { if httpResponse.statusCode == 401 { Auth().logout() } diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift index ec3230d..03edae3 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift @@ -30,7 +30,7 @@ import UIKit class AcronymsTableViewController: UITableViewController { // MARK: - Properties - var acronyms = [Acronym]() + var acronyms: [Acronym] = [] let acronymsRequest = ResourceRequest(resourcePath: "acronyms") // MARK: - View Life Cycle diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift index 9b0f005..6e98298 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift @@ -53,11 +53,17 @@ class CreateAcronymTableViewController: UITableViewController { } @IBAction func save(_ sender: UIBarButtonItem) { - guard let shortText = acronymShortTextField.text, !shortText.isEmpty else { + guard + let shortText = acronymShortTextField.text, + !shortText.isEmpty + else { ErrorPresenter.showError(message: "You must specify an acronym!", on: self) return } - guard let longText = acronymLongTextField.text, !longText.isEmpty else { + guard + let longText = acronymLongTextField.text, + !longText.isEmpty + else { ErrorPresenter.showError(message: "You must specify a meaning!", on: self) return } diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift index d23fbd9..32973d5 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift @@ -47,10 +47,10 @@ class CreateCategoryTableViewController: UITableViewController { guard let name = nameTextField.text, !name.isEmpty - else { - ErrorPresenter.showError( - message: "You must specify a name", on: self) - return + else { + ErrorPresenter.showError( + message: "You must specify a name", on: self) + return } let category = Category(name: name) diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift index 290147b..1232bef 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift @@ -46,17 +46,26 @@ class CreateUserTableViewController: UITableViewController { } @IBAction func save(_ sender: Any) { - guard let name = nameTextField.text, !name.isEmpty else { + guard + let name = nameTextField.text, + !name.isEmpty + else { ErrorPresenter.showError(message: "You must specify a name", on: self) return } - guard let username = usernameTextField.text, !username.isEmpty else { + guard + let username = usernameTextField.text, + !username.isEmpty + else { ErrorPresenter.showError(message: "You must specify a username", on: self) return } - guard let password = passwordTextField.text, !password.isEmpty else { + guard + let password = passwordTextField.text, + !password.isEmpty + else { ErrorPresenter.showError(message: "You must specify a password", on: self) return } diff --git a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift index b00d197..46b21e3 100644 --- a/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift +++ b/19-basic-authentication-part2/projects/final/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift @@ -34,12 +34,18 @@ class LoginTableViewController: UITableViewController { @IBOutlet weak var passwordTextField: UITextField! @IBAction func loginTapped(_ sender: UIBarButtonItem) { - guard let username = usernameTextField.text, !username.isEmpty else { + guard + let username = usernameTextField.text, + !username.isEmpty + else { ErrorPresenter.showError(message: "Please enter your username", on: self) return } - guard let password = passwordTextField.text, !password.isEmpty else { + guard + let password = passwordTextField.text, + !password.isEmpty + else { ErrorPresenter.showError(message: "Please enter your password", on: self) return } diff --git a/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/UsersController.swift b/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/UsersController.swift index ce09927..664b700 100644 --- a/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/UsersController.swift +++ b/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/UsersController.swift @@ -29,7 +29,6 @@ import Vapor struct UsersController: RouteCollection { - func boot(routes: RoutesBuilder) throws { let usersRoute = routes.grouped("api", "users") usersRoute.get(use: getAllHandler) diff --git a/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/WebsiteController.swift b/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/WebsiteController.swift index 0c62578..f982ad9 100644 --- a/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/WebsiteController.swift +++ b/19-basic-authentication-part2/projects/starter/TILApp/Sources/App/Controllers/WebsiteController.swift @@ -29,7 +29,6 @@ import Vapor struct WebsiteController: RouteCollection { - func boot(routes: RoutesBuilder) throws { routes.get(use: indexHandler) routes.get("acronyms", ":acronymID", use: acronymHandler) @@ -114,7 +113,7 @@ struct WebsiteController: RouteCollection { guard let id = acronym.id else { return req.eventLoop.future(error: Abort(.internalServerError)) } - var categorySaves = [EventLoopFuture]() + var categorySaves: [EventLoopFuture] = [] for category in data.categories ?? [] { categorySaves.append(Category.addCategory(category, to: acronym, on: req)) } @@ -156,7 +155,7 @@ struct WebsiteController: RouteCollection { let categoriesToAdd = newSet.subtracting(existingSet) let categoriesToRemove = existingSet.subtracting(newSet) - var categoryResults = [EventLoopFuture]() + var categoryResults: [EventLoopFuture] = [] for newCategory in categoriesToAdd { categoryResults.append(Category.addCategory(newCategory, to: acronym, on: req)) } diff --git a/19-basic-authentication-part2/projects/starter/TILApp/Tests/AppTests/AcronymTests.swift b/19-basic-authentication-part2/projects/starter/TILApp/Tests/AppTests/AcronymTests.swift index a0af4e8..4af187e 100644 --- a/19-basic-authentication-part2/projects/starter/TILApp/Tests/AppTests/AcronymTests.swift +++ b/19-basic-authentication-part2/projects/starter/TILApp/Tests/AppTests/AcronymTests.swift @@ -57,7 +57,6 @@ final class AcronymTests: XCTestCase { } func testAcronymCanBeSavedWithAPI() throws { - let user = try User.create(on: app.db) let createAcronymData = CreateAcronymData(short: acronymShort, long: acronymLong) try app.test(.POST, acronymsURI, beforeRequest: { request in diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS.xcodeproj/project.pbxproj b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS.xcodeproj/project.pbxproj index 9e5cfb0..f581510 100755 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS.xcodeproj/project.pbxproj +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS.xcodeproj/project.pbxproj @@ -171,7 +171,7 @@ isa = PBXNativeTarget; buildConfigurationList = D2A5F2121F4A9144005CD714 /* Build configuration list for PBXNativeTarget "TILiOS" */; buildPhases = ( - 2323AF6D24B7811400D2E1B6 /* ShellScript */, + 2323AF6D24B7811400D2E1B6 /* SwiftLint */, D2A5F1FC1F4A9144005CD714 /* Sources */, D2A5F1FD1F4A9144005CD714 /* Frameworks */, D2A5F1FE1F4A9144005CD714 /* Resources */, @@ -193,7 +193,7 @@ attributes = { LastSwiftUpdateCheck = 0900; LastUpgradeCheck = 1230; - ORGANIZATIONNAME = Razeware; + ORGANIZATIONNAME = "Ray Wenderlich"; TargetAttributes = { D2A5F1FF1F4A9144005CD714 = { CreatedOnToolsVersion = 9.0; @@ -234,7 +234,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 2323AF6D24B7811400D2E1B6 /* ShellScript */ = { + 2323AF6D24B7811400D2E1B6 /* SwiftLint */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -243,13 +243,14 @@ ); inputPaths = ( ); + name = SwiftLint; outputFileListPaths = ( ); outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -f ~/com.raywenderlich.swiftlint.yml ]; then\n if which swiftlint >/dev/null; then\n swiftlint --config ~/com.raywenderlich.swiftlint.yml\n fi\nfi\n"; + shellScript = "if [ -f ~/com.raywenderlich.swiftlint.yml ]; then\n if which swiftlint >/dev/null; then\n swiftlint --no-cache --config ~/com.raywenderlich.swiftlint.yml\n fi\nfi\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -421,7 +422,7 @@ DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/TILiOS/Project Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.razeware.TILiOS; + PRODUCT_BUNDLE_IDENTIFIER = com.raywenderlich.TILiOS; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = 1; @@ -436,7 +437,7 @@ DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/TILiOS/Project Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.razeware.TILiOS; + PRODUCT_BUNDLE_IDENTIFIER = com.raywenderlich.TILiOS; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = 1; }; diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/AppDelegate.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/AppDelegate.swift index 5c1bc7b..8b80fe5 100755 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/AppDelegate.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/AppDelegate.swift @@ -36,7 +36,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { if Auth().token == nil { let rootController = UIStoryboard(name: "Login", bundle: Bundle.main) .instantiateViewController(withIdentifier: "LoginNavigation") - self.window?.rootViewController = rootController + window?.rootViewController = rootController } return true } diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/Info.plist b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/Info.plist index 2feba9d..f87da23 100755 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/Info.plist +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/Info.plist @@ -20,6 +20,11 @@ 1 LSRequiresIPhoneOS + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -34,11 +39,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - UISupportedInterfaceOrientations~ipad UIInterfaceOrientationPortrait diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard index 4e46496..15d3c0b 100755 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Project Files/LaunchScreen.storyboard @@ -1,11 +1,9 @@ - - - - + + - - + + @@ -15,26 +13,27 @@ - + - + - + + - + @@ -42,7 +41,6 @@ - diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Utilities/AcronymRequest.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Utilities/AcronymRequest.swift index 959ce51..37449d0 100644 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Utilities/AcronymRequest.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/Utilities/AcronymRequest.swift @@ -92,9 +92,9 @@ struct AcronymRequest { let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200, let jsonData = data - else { - completion(.failure(.noData)) - return + else { + completion(.failure(.noData)) + return } do { let acronym = try JSONDecoder().decode(Acronym.self, from: jsonData) @@ -134,9 +134,9 @@ struct AcronymRequest { guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 201 - else { - completion(.failure(.invalidResponse)) - return + else { + completion(.failure(.invalidResponse)) + return } completion(.success(())) } diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift index ec3230d..03edae3 100644 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/AcronymsTableViewController.swift @@ -30,7 +30,7 @@ import UIKit class AcronymsTableViewController: UITableViewController { // MARK: - Properties - var acronyms = [Acronym]() + var acronyms: [Acronym] = [] let acronymsRequest = ResourceRequest(resourcePath: "acronyms") // MARK: - View Life Cycle diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift index 9b0f005..6e98298 100644 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateAcronymTableViewController.swift @@ -53,11 +53,17 @@ class CreateAcronymTableViewController: UITableViewController { } @IBAction func save(_ sender: UIBarButtonItem) { - guard let shortText = acronymShortTextField.text, !shortText.isEmpty else { + guard + let shortText = acronymShortTextField.text, + !shortText.isEmpty + else { ErrorPresenter.showError(message: "You must specify an acronym!", on: self) return } - guard let longText = acronymLongTextField.text, !longText.isEmpty else { + guard + let longText = acronymLongTextField.text, + !longText.isEmpty + else { ErrorPresenter.showError(message: "You must specify a meaning!", on: self) return } diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift index d23fbd9..32973d5 100644 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateCategoryTableViewController.swift @@ -47,10 +47,10 @@ class CreateCategoryTableViewController: UITableViewController { guard let name = nameTextField.text, !name.isEmpty - else { - ErrorPresenter.showError( - message: "You must specify a name", on: self) - return + else { + ErrorPresenter.showError( + message: "You must specify a name", on: self) + return } let category = Category(name: name) diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift index 290147b..1232bef 100644 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/CreateUserTableViewController.swift @@ -46,17 +46,26 @@ class CreateUserTableViewController: UITableViewController { } @IBAction func save(_ sender: Any) { - guard let name = nameTextField.text, !name.isEmpty else { + guard + let name = nameTextField.text, + !name.isEmpty + else { ErrorPresenter.showError(message: "You must specify a name", on: self) return } - guard let username = usernameTextField.text, !username.isEmpty else { + guard + let username = usernameTextField.text, + !username.isEmpty + else { ErrorPresenter.showError(message: "You must specify a username", on: self) return } - guard let password = passwordTextField.text, !password.isEmpty else { + guard + let password = passwordTextField.text, + !password.isEmpty + else { ErrorPresenter.showError(message: "You must specify a password", on: self) return } diff --git a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift index 2bd1863..3c0b967 100644 --- a/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift +++ b/19-basic-authentication-part2/projects/starter/TILiOS/TILiOS/ViewControllers/LoginTableViewController.swift @@ -34,12 +34,18 @@ class LoginTableViewController: UITableViewController { @IBOutlet weak var passwordTextField: UITextField! @IBAction func loginTapped(_ sender: UIBarButtonItem) { - guard let username = usernameTextField.text, !username.isEmpty else { + guard + let username = usernameTextField.text, + !username.isEmpty + else { ErrorPresenter.showError(message: "Please enter your username", on: self) return } - guard let password = passwordTextField.text, !password.isEmpty else { + guard + let password = passwordTextField.text, + !password.isEmpty + else { ErrorPresenter.showError(message: "Please enter your password", on: self) return }