Canvas = storyboard 화면
document outline = storyboard 내 문서 목록 창
inspector = 오른쪽 상세 화면 (size, attribute 등)
interface builder = 오 이게 IB인가봐!
Type aliases are helpful for referring to an existing type with a name that’s more expressive.
typealias DoneButtonAction = () -> Void
@IBOutlet var titleLabel: UILabel!
@IBOutlet var dateLabel: UILabel!
@IBOutlet var doneButton: UIButton!
var doneButtonAction: DoneButtonAction?
@IBAction func doneButtonTriggered(_ sender: UIButton) {
doneButtonAction?()
}
When initializing a view controller from a storyboard, iOS calls the init(coder:) initializer. This configure method approach is useful for configuring after initializing, such as injecting dependencies.
var reminder: Reminder?
func configure(with reminder: Reminder) {
self.reminder = reminder
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return ReminderRow.allCases.count
}
Tip
Always codify identifier strings to ensure your app doesn’t crash because of a mistyped identifier.