-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
연락처 관리 앱 [STEP3] JaeHyeok, Dora #43
Open
KSK9820
wants to merge
4
commits into
tasty-code:2_JaeHyeok
Choose a base branch
from
silverjaehyeok:STEP3
base: 2_JaeHyeok
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,47 +26,47 @@ class NewContactViewController: UIViewController { | |
phoneNumberTextField.delegate = self | ||
} | ||
|
||
func navigationSetting() { | ||
private func navigationSetting() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
navigationBar.isTranslucent = false | ||
navigationBar.shadowImage = UIImage() | ||
} | ||
|
||
func keyboardSetting() { | ||
private func keyboardSetting() { | ||
nameTextField.keyboardType = .namePhonePad | ||
ageTextField.keyboardType = .numberPad | ||
phoneNumberTextField.keyboardType = .phonePad | ||
} | ||
} | ||
|
||
extension NewContactViewController { | ||
@IBAction func tappedCancelButton(_ sender: UIButton) { | ||
cancelAlert() | ||
@IBAction private func tappedCancelButton(_ sender: UIButton) { | ||
showCancelAlert() | ||
} | ||
|
||
@IBAction func tappedSaveButton(_ sender: UIButton) { | ||
guard let name = nameCheck() else { | ||
@IBAction private func tappedSaveButton(_ sender: UIButton) { | ||
guard let name = checkName() else { | ||
invalidAlert(invalid: nameTextField) | ||
return | ||
} | ||
guard let age = ageCheck() else { | ||
guard let age = checkAge() else { | ||
invalidAlert(invalid: ageTextField) | ||
return | ||
} | ||
guard let number = numberCheck() else { | ||
guard let number = checkNumber() else { | ||
invalidAlert(invalid: phoneNumberTextField) | ||
return | ||
} | ||
saveAlert(Contact(name: name, phoneNumber: number, age: age)) | ||
} | ||
|
||
func cancelAlert() { | ||
private func showCancelAlert() { | ||
let alert = UIAlertController(title: title, message: "정말 취소하겠습니까?", preferredStyle: .alert) | ||
alert.addAction(UIAlertAction(title: "예", style: .destructive, handler: { _ in self.dismiss(animated: true)})) | ||
alert.addAction(UIAlertAction(title: "아니오", style: .default, handler: nil)) | ||
present(alert, animated: true) | ||
} | ||
|
||
func saveAlert(_ contact: Contact) { | ||
private func showSaveAlert(_ contact: Contact) { | ||
let text: String = "이름: \(contact.name), \n 나이: \(contact.age), \n 연락처: \(contact.phoneNumber) \n 저장하시겠습니까?" | ||
let alert = UIAlertController(title: title, message: text, preferredStyle: .alert) | ||
alert.addAction(UIAlertAction(title: "예", style: .default, handler: { _ in | ||
|
@@ -76,28 +76,28 @@ extension NewContactViewController { | |
present(alert, animated: true) | ||
} | ||
|
||
func nameCheck() -> String? { | ||
private func checkName() -> String? { | ||
guard let name = nameTextField.text else { | ||
return nil | ||
} | ||
return name == "" ? nil : name.components(separatedBy: " ").joined() | ||
return name.isEmpty ? nil : name.components(separatedBy: " ").joined() | ||
} | ||
|
||
func ageCheck() -> Int? { | ||
private func checkAge() -> Int? { | ||
guard let ageText = ageTextField.text, let age = Int(ageText) else { | ||
return nil | ||
} | ||
return age | ||
} | ||
|
||
func numberCheck() -> String? { | ||
private func checkNumber() -> String? { | ||
guard let number = phoneNumberTextField.text else { | ||
return nil | ||
} | ||
return number.count >= 11 && number.filter { $0 == "-" }.count == 2 ? number : nil | ||
} | ||
|
||
func invalidAlert(invalid: UITextField) { | ||
private func invalidAlert(invalid: UITextField) { | ||
var text: String | ||
|
||
switch invalid { | ||
|
@@ -123,7 +123,6 @@ extension NewContactViewController: UITextFieldDelegate { | |
|
||
if range.location == 2 && number.last != "-" { | ||
number.insert("-", at: number.index(number.startIndex, offsetBy: 2)) | ||
print(number.count) | ||
} | ||
|
||
if range.location == 6 && number.last != "-" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금처럼
searchText
프로퍼티를 검색 텍스트로 사용하는 것도 좋은 방법이라고 생각합니다🙂