2017-11-27 3 views
-3

코드를 Swift 4로 업그레이드 했으므로 이제 모든 tableView 기능에 대해 콘솔에서이 경고를 수신했습니다.tableview 함수에 대해 "사용되지 않으며 Swift 4에서 제거됩니다"라는 경고 수정

tableView:willDisplayCell:forRowAtIndexPath:] is deprecated and will be removed in Swift 4; add explicit '@objc' to the declaration to emit the Objective-C entrypoint in Swift 4 and suppress this message 

tableView:cellForRowAtIndexPath:] is deprecated and will be removed in Swift 4 

답변

-2

이 경고를 수정하려면 모든 tableView 함수의 맨 앞에 "@objc"를 추가해야합니다. 이처럼

: 하나 아래 cellForRow

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
} 

사용을위한 코드 아래

@objc func tableView(_ tableView: UITableView!, numberOfRowsInSection section: Int) -> Int { 
    return 1 
} 
0

사용하면 의심의 여지 데이터 소스 및 위임에 관한 한 경우

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 
} 

를 표시하는 세포를 식별 할 수 함수 선택 UITableViewDataSource 또는 UITableViewDelegate 및 오른쪽 클릭하여 정의로 이동하면 기능을 얻을 수 있습니다.

희망이 도움이 될 것입니다

관련 문제