Swift(12)
-
[ Swift ] Keyboard 제어
키보드 컨트롤 쉽지 않지만 이것을 기억하자 ! //다른 곳 터치하면 키보드 내리기 override func touchesBegan(_ touches: Set, with event: UIEvent?) { self.view.endEditing(true) }
2020.12.21 -
[ Swift ] Table View Cell 에 stack View 를 추가해보자.
결과물 일단 UIView의 Anchor를 설정하는 함수(setAnchor)를 사용하기 위해 extension을 작성해줍니다. extension UIView { func setAnchor(top: NSLayoutYAxisAnchor?, left: NSLayoutXAxisAnchor?, bottom: NSLayoutYAxisAnchor?, right: NSLayoutXAxisAnchor?, paddingTop: CGFloat, paddingLeft: CGFloat, paddingBottom: CGFloat, paddingRight: CGFloat) { self.translatesAutoresizingMaskIntoConstraints = false if let top = top { self.topAnchor..
2020.11.19 -
[ Swift ] Grammar
?? Double question mark is a nil-coalescing operator. In plain terms, it is just a shorthand for saying != nil First it checks if the return value is nil, if it is indeed nil, then the left value is presented, and if it is nil then the right value is presented.
2020.11.04 -
[ Swift ] font 바꾸기
www.xspdf.com/resolution/51668213.html How to change the color of the button title in Swift Uibutton title not showing swift UIButton title not displaying, I just started developing in Swift. I created an UIButton dynamically and added it to the View. My issue is the view is not displaying the button. My I just started developing in Swift. I cr www.xspdf.com font 바꾸는 자료이다! 좋은 글이지만 코드가 텍스트하고 섞여 있..
2020.11.04 -
[ Swift ] Protocol ? Extension ?
상속( inheritance ) 위임( delegate ) 프로토콜( Protocol )은 특정 역할을 수행하기 위한 메서드 , 프로퍼티, 기타 요구사항 등의 청사진을 정의합니다. 구조체, 클래스, 열거형 프로토콜은 채택( Adopted ) 해서 특정 기능을 수행하기 위한 프로토코 요구사항을 실제로 구현할 수 있습니다. 어떤 프로토콜의 요구사항을 모두 따르는 타입은 그 '프로토콜을 준수한다( Conform )'고 표현합니다. 타입에서 프로토콜의 요구사항을 충족시키려면 프로토콜이 제시하는 청사진의 기능을 모두 구현해야 합니다. 즉, 프로토콜은 기능을 정의하고 제시할 뿐이지 스스로 기능을 구현하지는 않습니다. 프로토콜 정의 프로토콜은 구조체, 클래스, 열거형의 모양과 비슷하게 정의할 수 있으며 protoco..
2020.10.30 -
[ Swift ] 단축키
Opt + command + enter >> 미리보기 창 열기 Opt + command + P >> 미리보기 실행
2020.10.27 -
[ Swift ] DispatchQueue
Dispatch Queue 의 타입 1. Main Queue(.main) 2. Global Queue(.global(qos: .background)) 3. Custom Queue let concurrentQueue = DispatchQueue(label: "concurrent", qos: .background, attributes: .concurrent) let serialQueue = DispatchQueue(label: "serial", qos: .background) 1- 메인 스레드에서 작동하는 큐 2- QoS (Quality of Service) 의 순위를 매겨놓은것. 1) userInteractive// 바로 수행되어야할 작업들 2) userInitiated// 사용자가 결과를 기다리는 작업 ..
2020.10.21 -
[ Swift ] http data 가져오기 data trimming
import UIKit import Foundation// replacingOccurrences을 사용하기 위해서 class ViewController: UIViewController { @IBOutlet weak var txtResponse: UITextView! let strUrl : String = "http://192.168.0.11:3000" override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() /..
2020.10.15 -
[ Swift ] @IBAction 소스 분석해보기
@IBOutlet var lblHello: UILabel! @IBOutlet : IBOutlet으로 정의된 변수를 아웃렛 변수라 부릅니다. 여기서 IB는 Interface Builder의 약자로, @IB로 시작되는 변수나 함수는 인터페이스 빌더와 관련된 변수나 함수라는것을 의미합니다. @IBOutlet은 객체를 소스 코드에서 참조하기 위해 사용하는 키워드이며 주로 색상, 크기, 모양. 선의 두께, 텍스트 내용 등 객체의 속성을 제어하는 데 사용합니다. var lblHello : 변수를 선언할 때는 var 키워드를 사용합니다. 변수를 선언하는 var 뒤에 아웃렛 변수의 이름 lblHello를 입력하여 변수를 선언합니다. UILabel! : 선언하고자 하는 변수의 타입을 나타냅니다. 위 예제에서는 레이블 객..
2020.10.14 -
[ Swift ] Tuples
// 0 1 let studentMark: (String, Int) = ("Chris", 46) studentMark.0 // "Chris" studentMark.1 // 46 //012 let studentData = (name: "Chris", mark: 46, petName: "Mango") let theName = studentData.name let theMark = studentData.mark let thePetName = studentData.petName let (name, mark, petName) = studentData //
2020.10.06