전체 글

개발/아이오에스

swift] KVO 사용 tableview의 높이 동적으로 할당

mCon.tableView.addObserver(self, forKeyPath: "contentSize", options: .new, context: nil) override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { // //알림 추가/제거에 따른 테이블뷰의 높이 값 변경하기 // if keyPath == "contentSize" { if let newValue = change?[.newKey] { // print("->newValue",newValue) if let newSize = newValue..

개발/아이오에스

swift] 상황(조건)에 맞는 NSLayoutConstraint 처리

struct TransitionCst { var tableViewHeight : NSLayoutConstraint? var existListConstraitY : NSLayoutConstraint? var existListConstraitN : NSLayoutConstraint? } 스크롤뷰안에 뷰의 bottomAnchor은 스크롤의 길이를 결정 - viewInScroll.bottomAnchor mCst.existListConstraitY = mCon.tableView.bottomAnchor.constraint(equalTo: mCon.viewInScroll.bottomAnchor) mCst.existListConstraitN = mCon.emptyText.bottomAnchor.constraint(eq..

개발/아이오에스

[swift] contains

var test = [1,2,3,4] let testcon = test.contains { (testData) -> Bool in return testData == 3 } testcon // true 이전에 contains을 사용해서 해당 배열크기만큼 돌면서 체크를 하는 것을 알고있었지만 해당 리턴값이 하나라도 true라면 그 값이 true로 정해지는지 몰랐다. 예시 코드에서 리턴값은 false, false, true, false 값이지만 결국 true가 하나라도 존재하기 때문에 testcon이라는 변수는 true가 된다.

개발/아이오에스

swift] filter 사용 bool 배열에서 true값 찾아내기

mV.isSelecteds: [bool] = [bool]() let cnt = mV.isSelecteds.filer { (bol) -> Bool in return bol } print(cnt) - [true, true, true] print(cnt.count) - 3

개발/아이오에스

swift] bool 타입 배열 초기화 하는방법

var isSelecteds : [Bool] = [Bool]() mV.isSelecteds = Array.init(repeating: false, count: tmpArrs.count) count: 2 일때 // -> [false, false] mV.isSelecteds = [Bool]() //다시 초기화 // -> []

카테고리 없음

[swift] class 사용 enum 활용하기

class AlarmInfo: NSObject, NSCoding { var sound : eSound = .talkCM init(sound : eSound){ self.sound = sound } } enum eSound : Int { case talkCM case twoSecond case original case first var name: String { switch self { case .first : return "1위" } } var songName: String { switch self { case .first : return "alarm_6_china.mp3" } } } -------- fun test(info: [AlarmInfo]) { info.forEach { (data) in dat..

dev.jake
484jake