프로토콜은 특정 객체가 갖추어야 할 기능이나 속성에 대한 설계도
프로토콜은 선언 형태를 갖는다. 실질적인 내용은 이 프로토콜을 이용하는 객체에서 정의한다.
protocol CalculatorProtocol {
func add(op1: Int, op2: Int) -> Int
func sub(op1: Int, op2: Int) -> Int
}
CalculatorProtocol 프로토콜을 상속받은 클래스는 반드시 add, sub 함수를 만들어야한다.
class SimpleCalculator : CalculatorProtocol {
func add(op1: Int, op2: Int) -> Int {
return op1 + op2
}
func sub(op1: Int, op2: Int) -> Int {
return op1 - op2
}
}
뷰 컨트롤러가 스택에 푸시하면서 최상단으로 불러와짐. 이전화면으로 돌아가면 pop되면서 스택의 최상단 화면이 나타남
navigation.navigate(“page”)랑 비슷한 느낌인듯
Show랑 비슷하지만 push가 아니라 replace, 즉 교체됨
navigation.push(“page”) 같은 느낌이랄까
뷰를 모달형태로 보여줌
현재 보이는 뷰 컨트롤러 위에 앵커를 가진 팝업 형태로 콘텐츠 뷰를 표시함
-> 뭔소린지 몰라 좀 찾아보니 책과 콩나무 수정/삭제 버튼 눌렀을 때 사용한 Tooltip 라이브러리같이 생긴 형태
말 그대로 개발자가 임의로 설정한 동작을 수행함
Thread 1: "unable to dequeue a cell with identifier reuseIdentifier - must register a nib or a class for the identifier or connect a prototype cell in a storyboard"
tableView를 오버라이드 한 파일 만들때 주석으로 만들어주는 함수에 보면
let cell = tableView.dequeuereusableCell(withIdentifier : "~~"가 있는데
~~ 자리에 내가 설정한 cell의 identifier를 넣어주지 않았기 때문에 발생
withIdentifier에 reuseIdentifier말고 내가 설정한 identifier를 넣어주면됨.
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
cell.textLabel?.text = items[(indexPath as NSIndexPath).row]
cell.imageView?.image = UIImage(named: itemsImageFile[(indexPath as NSIndexPath).row])
return cell
}
뷰가 처음 보일 때 한 개의 함수로만 호출해 보여 주는 것이 아니라 여러 개의 함수가 호출되는데, 호출되는 함수의 순서는 ViewDidLoad -> ViewWillAppear -> ViewDidAppear순이다. 하지만 뷰가 전환되어 올 때는 ViewWillAppear -> ViewDidAppear만 호출된다.