This file contains hidden or 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
| class User { | |
| var nickname: String | |
| var age: Int | |
| init(nickname: String, age: Int) { | |
| // init | |
| self.nickname = nickname | |
| self.age = age | |
| } |
This file contains hidden or 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
| protocol name { | |
| // body | |
| } |
This file contains hidden or 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
| extension name { | |
| // addition | |
| } |
This file contains hidden or 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
| enum Student { | |
| case Name(String) | |
| case Mark(Int,Int,Int) | |
| } | |
| var studDetails = Student.Name("Swift") | |
| var studMarks = Student.Mark(98,97,95) | |
| switch studMarks { | |
| case .Name(let studName): | |
| print("Student name is: \(studName).") | |
| case .Mark(let Mark1, let Mark2, let Mark3): |
This file contains hidden or 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
| do { | |
| try 표현식 결과 | |
| } catch 패턴 1 { | |
| 처리 결과 | |
| } catch 패턴 2 where 조건 { | |
| 처리 결과 | |
| } catch { | |
| 처리 결과 | |
| } |
This file contains hidden or 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
| enum PhoneError: Error { case unknown case batteryLow(batteryLevel: Int) } | |
| throw PhoneError.batteryLow(batteryLevel: 20) | |
| - 던져진 오류를 처리하기 위한 작업이 필요하다 | |
| ```swift | |
| func checkPhoneBatteryStatus(batteryLevel: Int) throws -> String { | |
| guard batteryLevel != -1 else { throw PhoneError.unknown } | |
| guard batteryLevel > 20 else { throw PhoneError.batteryLow(batteryLevel: batteryLevel) } | |
| return "배터리 상태 정상" | |
| } |
This file contains hidden or 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
| { (param) -> return type in | |
| // body | |
| } |
This file contains hidden or 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
| if (@available(iOS 15.0, *)) { | |
| [[UITableView appearance] setSectionHeaderTopPadding:0.0f]; | |
| } else { | |
| // Fallback on earlier versions | |
| } |
This file contains hidden or 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
| import UIKit | |
| class CustomInputView: UIInputView { | |
| override init(frame: CGRect, inputViewStyle: UIInputView.Style) { | |
| super.init(frame: frame, inputViewStyle: inputViewStyle) | |
| } | |
| required init?(coder: NSCoder) { | |
| super.init(coder: coder) | |
| } |
This file contains hidden or 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
| import UIKit | |
| class ViewController: UIViewController { | |
| lazy var textField: UITextField = UITextField() | |
| lazy var label: UILabel = UILabel() | |
| lazy var btn: UIButton = UIButton() | |
| lazy var safeArea = view.safeAreaLayoutGuide | |
| lazy var isCustomInputView = false | |
| override func viewDidLoad() { |