Skip to content

Commit

Permalink
4차과제
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyoungsophia committed May 22, 2020
1 parent cddd177 commit c23df63
Show file tree
Hide file tree
Showing 160 changed files with 920 additions and 86 deletions.
Binary file modified iOS_Week1_Exercise_Login/.DS_Store
Binary file not shown.
11 changes: 11 additions & 0 deletions iOS_Week1_Exercise_Login/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'iOS_Week1_Exercise_Login' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for iOS_Week1_Exercise_Login
pod 'Alamofire', '~> 4.8.2'
pod 'Kingfisher', '~> 5.0'
end
22 changes: 22 additions & 0 deletions iOS_Week1_Exercise_Login/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PODS:
- Alamofire (4.8.2)
- Kingfisher (5.14.0):
- Kingfisher/Core (= 5.14.0)
- Kingfisher/Core (5.14.0)

DEPENDENCIES:
- Alamofire (~> 4.8.2)
- Kingfisher (~> 5.0)

SPEC REPOS:
trunk:
- Alamofire
- Kingfisher

SPEC CHECKSUMS:
Alamofire: ae5c501addb7afdbb13687d7f2f722c78734c2d3
Kingfisher: 7b64389a43139c903ec434788344c288217c792d

PODFILE CHECKSUM: b6ab108c6bf59e4a237a898ad00979def63c26b6

COCOAPODS: 1.9.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
349659700DBA20FCFD366532 /* Pods_iOS_Week1_Exercise_Login.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E2DFE169092531CCCFF6462 /* Pods_iOS_Week1_Exercise_Login.framework */; };
CC2A6928244AEA7F00379EA9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A6927244AEA7F00379EA9 /* AppDelegate.swift */; };
CC2A692A244AEA7F00379EA9 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A6929244AEA7F00379EA9 /* SceneDelegate.swift */; };
CC2A692C244AEA7F00379EA9 /* SignUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A692B244AEA7F00379EA9 /* SignUpViewController.swift */; };
Expand All @@ -15,9 +16,16 @@
CC2A6934244AEA8200379EA9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CC2A6932244AEA8200379EA9 /* LaunchScreen.storyboard */; };
CC2A693C244AF1D100379EA9 /* LogoutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A693B244AF1D100379EA9 /* LogoutViewController.swift */; };
CC2A693E244AF67F00379EA9 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC2A693D244AF67F00379EA9 /* LoginViewController.swift */; };
CCD627B4246FBBB700B6E6AF /* APIConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCD627B3246FBBB700B6E6AF /* APIConstants.swift */; };
CCD627B6246FBE4F00B6E6AF /* SigninData.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCD627B5246FBE4F00B6E6AF /* SigninData.swift */; };
CCD627B8246FBFC400B6E6AF /* NetworkResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCD627B7246FBFC400B6E6AF /* NetworkResult.swift */; };
CCD627BA246FC57F00B6E6AF /* LoginService.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCD627B9246FC57F00B6E6AF /* LoginService.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
4E2DFE169092531CCCFF6462 /* Pods_iOS_Week1_Exercise_Login.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_iOS_Week1_Exercise_Login.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4E674989BED31BCEC55105C0 /* Pods-iOS_Week1_Exercise_Login.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS_Week1_Exercise_Login.debug.xcconfig"; path = "Target Support Files/Pods-iOS_Week1_Exercise_Login/Pods-iOS_Week1_Exercise_Login.debug.xcconfig"; sourceTree = "<group>"; };
6E8DF582EB3CCA5B78D044AF /* Pods-iOS_Week1_Exercise_Login.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOS_Week1_Exercise_Login.release.xcconfig"; path = "Target Support Files/Pods-iOS_Week1_Exercise_Login/Pods-iOS_Week1_Exercise_Login.release.xcconfig"; sourceTree = "<group>"; };
CC2A6924244AEA7F00379EA9 /* iOS_Week1_Exercise_Login.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOS_Week1_Exercise_Login.app; sourceTree = BUILT_PRODUCTS_DIR; };
CC2A6927244AEA7F00379EA9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
CC2A6929244AEA7F00379EA9 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -28,24 +36,48 @@
CC2A6935244AEA8200379EA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CC2A693B244AF1D100379EA9 /* LogoutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutViewController.swift; sourceTree = "<group>"; };
CC2A693D244AF67F00379EA9 /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
CCD627B3246FBBB700B6E6AF /* APIConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIConstants.swift; sourceTree = "<group>"; };
CCD627B5246FBE4F00B6E6AF /* SigninData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigninData.swift; sourceTree = "<group>"; };
CCD627B7246FBFC400B6E6AF /* NetworkResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkResult.swift; sourceTree = "<group>"; };
CCD627B9246FC57F00B6E6AF /* LoginService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginService.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
CC2A6921244AEA7F00379EA9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
349659700DBA20FCFD366532 /* Pods_iOS_Week1_Exercise_Login.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5358251427CF75479FCD770A /* Pods */ = {
isa = PBXGroup;
children = (
4E674989BED31BCEC55105C0 /* Pods-iOS_Week1_Exercise_Login.debug.xcconfig */,
6E8DF582EB3CCA5B78D044AF /* Pods-iOS_Week1_Exercise_Login.release.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
B4FC0AE0716C13BEBDC48EC5 /* Frameworks */ = {
isa = PBXGroup;
children = (
4E2DFE169092531CCCFF6462 /* Pods_iOS_Week1_Exercise_Login.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
CC2A691B244AEA7F00379EA9 = {
isa = PBXGroup;
children = (
CC2A6926244AEA7F00379EA9 /* iOS_Week1_Exercise_Login */,
CC2A6925244AEA7F00379EA9 /* Products */,
5358251427CF75479FCD770A /* Pods */,
B4FC0AE0716C13BEBDC48EC5 /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -60,6 +92,7 @@
CC2A6926244AEA7F00379EA9 /* iOS_Week1_Exercise_Login */ = {
isa = PBXGroup;
children = (
CCD627BB246FC59000B6E6AF /* Resource */,
CC2A693F244AFD4E00379EA9 /* VC */,
CC2A6927244AEA7F00379EA9 /* AppDelegate.swift */,
CC2A6929244AEA7F00379EA9 /* SceneDelegate.swift */,
Expand All @@ -81,16 +114,29 @@
path = VC;
sourceTree = "<group>";
};
CCD627BB246FC59000B6E6AF /* Resource */ = {
isa = PBXGroup;
children = (
CCD627B3246FBBB700B6E6AF /* APIConstants.swift */,
CCD627B5246FBE4F00B6E6AF /* SigninData.swift */,
CCD627B7246FBFC400B6E6AF /* NetworkResult.swift */,
CCD627B9246FC57F00B6E6AF /* LoginService.swift */,
);
path = Resource;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
CC2A6923244AEA7F00379EA9 /* iOS_Week1_Exercise_Login */ = {
isa = PBXNativeTarget;
buildConfigurationList = CC2A6938244AEA8200379EA9 /* Build configuration list for PBXNativeTarget "iOS_Week1_Exercise_Login" */;
buildPhases = (
2524AC933647951BF76E8A5A /* [CP] Check Pods Manifest.lock */,
CC2A6920244AEA7F00379EA9 /* Sources */,
CC2A6921244AEA7F00379EA9 /* Frameworks */,
CC2A6922244AEA7F00379EA9 /* Resources */,
C6A05B0A0E0515B1F62A900B /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -147,16 +193,62 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
2524AC933647951BF76E8A5A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-iOS_Week1_Exercise_Login-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
C6A05B0A0E0515B1F62A900B /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-iOS_Week1_Exercise_Login/Pods-iOS_Week1_Exercise_Login-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-iOS_Week1_Exercise_Login/Pods-iOS_Week1_Exercise_Login-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-iOS_Week1_Exercise_Login/Pods-iOS_Week1_Exercise_Login-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
CC2A6920244AEA7F00379EA9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CC2A692C244AEA7F00379EA9 /* SignUpViewController.swift in Sources */,
CC2A6928244AEA7F00379EA9 /* AppDelegate.swift in Sources */,
CCD627B4246FBBB700B6E6AF /* APIConstants.swift in Sources */,
CC2A693C244AF1D100379EA9 /* LogoutViewController.swift in Sources */,
CCD627BA246FC57F00B6E6AF /* LoginService.swift in Sources */,
CCD627B6246FBE4F00B6E6AF /* SigninData.swift in Sources */,
CC2A693E244AF67F00379EA9 /* LoginViewController.swift in Sources */,
CC2A692A244AEA7F00379EA9 /* SceneDelegate.swift in Sources */,
CCD627B8246FBFC400B6E6AF /* NetworkResult.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -298,6 +390,7 @@
};
CC2A6939244AEA8200379EA9 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4E674989BED31BCEC55105C0 /* Pods-iOS_Week1_Exercise_Login.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
Expand All @@ -315,6 +408,7 @@
};
CC2A693A244AEA8200379EA9 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 6E8DF582EB3CCA5B78D044AF /* Pods-iOS_Week1_Exercise_Login.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="로그인하기"/>
<connections>
<action selector="login:" destination="BYZ-38-t0r" eventType="touchUpInside" id="Z44-PO-Pni"/>
<action selector="transferData:" destination="BYZ-38-t0r" eventType="touchUpInside" id="EYe-8R-s4q"/>
</connections>
</button>
Expand Down Expand Up @@ -137,6 +138,20 @@
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="이름" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KhG-1G-iO2">
<rect key="frame" x="87" y="532" width="30" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="email" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3SO-0F-hUJ">
<rect key="frame" x="87" y="573" width="41" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="DHp-hf-e6V"/>
Expand Down
5 changes: 5 additions & 0 deletions iOS_Week1_Exercise_Login/iOS_Week1_Exercise_Login/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<string>YES</string>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// APIConstants.swift
// iOS_Week1_Exercise_Login
//
// Created by 양지영 on 2020/05/16.
// Copyright © 2020 양지영. All rights reserved.
//
import Foundation

struct APIConstants {
static let baseURL = "http://13.209.144.115:3333"
static let signinURL = APIConstants.baseURL + "/user/signin"
static let signupURL = APIConstants.baseURL + "/user/signup"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// LoginService.swift
// iOS_Week1_Exercise_Login
//
// Created by 양지영 on 2020/05/16.
// Copyright © 2020 양지영. All rights reserved.
//

import Foundation
import Alamofire

struct LoginService {
static let shared = LoginService() // shared:전역으로 사용가능, static let어디서든 접근 가능
private func makeParameter(_ id: String, _ pwd: String) -> Parameters {
return ["id": id, "password":pwd]
}
func login(id: String, pwd: String, completion: @escaping (NetworkResult<Any>) -> Void) {
let header: HTTPHeaders = ["Content-Type": "application/json"] //httpheaders는 alanmofire 레퍼런스
// 요청에해당하는 객체 생성
let dataRequest = Alamofire.request(APIConstants.signinURL, method: .post, parameters: makeParameter(id, pwd), encoding: JSONEncoding.default, headers: header)
//데이터 통신시작
dataRequest.responseData { dataResponse in
switch dataResponse.result {
case .success:
// statuscode를 헤더에 넣을경우 분기처리 적게해서 더 좋음(?), 지금은 쪼개면서 2번 분기처리
guard let statusCode = dataResponse.response?.statusCode else { return }
guard let value = dataResponse.result.value else { return }
let networkResult = self.judge(by: statusCode, value)
completion(networkResult)
case .failure: completion(.networkFail)
}
}
}
private func judge(by statusCode: Int, _ data: Data) -> NetworkResult<Any> {
switch statusCode {
case 200: return isUser(by: data) //데이터를 넣어서 판단 시작
case 400: return .pathErr
case 500: return .serverErr
default: return .networkFail
}
}
// 디코딩해줄 객체
private func isUser(by data: Data) -> NetworkResult<Any> {
let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(SigininData.self, from: data) else { return .pathErr }
guard let tokenData = decodedData.data else { return .requestErr(decodedData.message) }
return .success(tokenData.jwt)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// NetworkResult.swift
// iOS_Week1_Exercise_Login
//
// Created by 양지영 on 2020/05/16.
// Copyright © 2020 양지영. All rights reserved.
//

import Foundation

enum NetworkResult<T> {
case success(T)
case requestErr(T)
case pathErr
case serverErr
case networkFail
}
Loading

0 comments on commit c23df63

Please sign in to comment.