본문 바로가기

Swift

(57)
NavigationBar가 hidden일 경우 뒤로 가기 처음에 NavigationBar가 없을 때에는 self.dismissViewControllerAnimated(true, completion: nil)로 view를 닫았는데 NavigationBar를 달아놓으니 이게 안 먹는 것이다.그런데 마침 이 View에서는 self.navigationController?.setNavigationBarHidden(true, animated: true) 상태라 뒤로 가기 버튼이 보이지 않는다. 검색을 좀 해 보니, 이런 경우에는 다음 함수를 이용해서 뒤로 갈 수 있다고 한다.self.navigationController?.popViewControllerAnimated(true) 참고로 popView의 반대 개념은 self.navigationController?.pushV..
UIStackView 참고 사이트 https://makeapppie.com/2015/11/11/how-to-add-stack-views-programmatically-and-almost-avoid-autolayout/
xcode에 swift realm 적용하기 (swift 2.2 기준) 우선 Realm 사이트에서 소스를 다운받는다: https://realm.io/docs/swift/latest/아래의 순서대로 설정하면 된다. 그런데 나 같은 초짜는 이것도 하기 힘들다.한글 사이트는 이 글을 쓰는 시점에서 2.2에 대한 해석은 되어 있지 않았다. Download the latest release of Realm and extract the zip.Go to your Xcode project’s “General” settings. DragRealmSwift.framework and Realm.framework from the ios/swift-2.2/,watchos/, tvos/ or osx/swift-2.2/ directory to the “Embedded Binaries” section..
segue의 5가지 유형 segue의 5가지 유형 설명이 잘 되어 있는 글을 발견. 출처: http://theeye.pe.kr/archives/2292 혹시 블로그 폐쇄를 우려하여 일부 내용을 여기에 적어놓는다. show : 화면에 보여지고 있는 마스터 또는 디테일 영역에 뷰를 로드합니다. 마스터와 디테일 영역 모두 화면에 보여지고 있을 경우 로드되는 새로운 컨텐츠 뷰는 디테일 영역의 네비게이션 스택에 푸시 됩니다. 마스터와 디테일 영역중 하나만 보여지고 있을 경우 현재 뷰컨트롤러 스택의 최상단에 푸시됩니다. show detail : show와 매우 비슷하지만 푸시가 아닌 교체(replace)된다는 점이 크게 다릅니다. 마스터와 디테일 영역 모두 화면에 보여지고 있을 경우 로드되는 뷰는 디테일 영역을 교체하게 되며 둘중 하나만 ..
스위프트에서 기본 제공하는 폰트들 fonts in swift 다음과 같은 코드로 목록을 얻을 수 있다. func printFonts() { for familyName in UIFont.familyNames() { print("familyName=\(familyName)") for fontname in UIFont.fontNamesForFamilyName(familyName) { print("fontname=\(fontname)") } } } familyName=Thonburifontname=Thonburi-Boldfontname=Thonburifontname=Thonburi-LightfamilyName=Khmer Sangam MNfontname=KhmerSangamMNfamilyName=Kohinoor Telugufontname=KohinoorTelugu-Regu..
배열 검색 in swift 출처 : http://locomoviles.com/uncategorized/filtering-swift-array-dictionaries-object-property/ 배열 검색에 대해서 여러 사이트를 찾아 보았으나 이 사이트가 가장 깔끔하게 정리된 것 같다.그냥 배열일 때딕셔너리 일 때구조체 일 때에 대해서 어떻게 필터 조건을 주는지 설명하고 있다. 아래는 해당 사이트가 폐쇄될 것을 대비하여 내용을 복사해 놓은 것. To filter a simple swift array you just need to use the “filter” method like below.123456var simpleArray = [22, 41, 23, 30] var filteredArray = simpleArray.filter..
selector in swift selector 사용법이 좀 바뀌었는데 예전 사용법이 너무 많이 검색된다.문자열을 메소드로 인식시키는 예전 방법이 error 유발 가능성은 더 크지만 유연한 사용법을 제시할 수 있어 더 좋았던 것 같다.지금은 이런 식으로 사용하려면 어찌해야 하는지.. 역시 스위프트 공홈에서 퍼왔다. In Swift 2.1, code like the below would compile with no problems:override func viewDidLoad() { super.viewDidLoad() navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "addNewFireflyRefernce"..
for loop in swift 스위프트의 for 구문 : 역순 루프도 참고하시라.스위프트 공식 홈피에 있는 글인데 검색이 잘 안 되서리 퍼왔다. Even though Swift has several idiomatic loop options, C-style for loops were still part of the language and occasionally used. For example:for var i = 0; i