모든 프로토콜에는이를 준수하기 위해 구현해야하는 일련의 메소드가 있습니다. 당신은 그것들을 따르기 위해 당신의 클래스에 그 메소드들을 작성해야한다. 이 프로토콜을 완벽하게 구현되지 않습니다,
class ViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {
}
을하지만 : 당신이있는 tableView를하기로 결정한 경우
는 예를 들어,있는 UIViewController에, 당신은 지금처럼 UITableViewDataSource
, UITableViewDelegate
프로토콜을 추가해야합니다. 이것은 단순한 선언입니다.
실제로보기 컨트롤러가 프로토콜을 준수하게하려면 두 가지 방법, 즉 cellForRowAtIndexPath
및 numberOfRowsInSection
을 구현해야합니다. 이것은 프로토콜의 요구 사항입니다.
class ViewController : UIViewController, UITableViewDataSource, UITableViewDelegate {
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cellID", forIndexPath: indexPath) as! ExperienceCell
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 0
}
}
따라서, 당신은 문서로보고 방법이 프로토콜을 구현하는 클래스를 필요로 무엇을 발견해야한다 :
그래서 완전한 구현은 같을 것입니다. 그러면이 문제가 해결됩니다. 그리고 나는 그것이 엑스 코드 8 빠른 3
EDIT 여기으로 아무것도 할 생각하지 않는다 : 이것은 apple documentation says
Most methods of this protocol are optional. You implement the methods you need to respond to the data transfer operations that your apps support. However, apps should implement support for the session:activationDidCompleteWithState:error: method to support asynchronous activation, and the delegate in your iPhone app should implement the sessionDidBecomeInactive: and sessionDidDeactivate: methods to support multiple Apple Watches.
프로젝트를 만들었습니까/청소 했습니까? –
@AkshanshThakur 예, 여러 번 – Devhess
빌드 출력에서 전체 오류를 읽으면 프로토콜을 따르지 않는 방법을 알려줍니다. –