iOS 15 가 나오고 Xcode 13이 나오면서 textLabel에 deprecated 가 떴다.

애플 개발자 문서

 

Apple Developer Documentation

 

developer.apple.com

그래서 테이블 셀 내용 호출하는 방식이 달라졌다.

 

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "MessageCell", for: indexPath)
        
        // 달라진 방식(iOS 14.0 이상)
        if #available(iOS 14.0, *) {
            var content = cell.defaultContentConfiguration()
            content.text = self.comments[indexPath.row].message
            cell.contentConfiguration = content
        } else {
        // 기존과 동일(iOS 14.0 까지만 지원)
            cell.textLabel?.text = self.comments[indexPath.row].message
        }
        
        return cell
    }

 

+ Recent posts