2016-12-28 50 views
-2
// QuizPopUpViewController.swift 
@objc protocol QuizPopUpViewControllerDelegate { 
    func ApplyNowToSendBack() 
} 

class QuizPopUpViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UITextViewDelegate { 
    weak var delegate: QuizPopUpViewControllerDelegate? 
} 


// giving event from here 
if isError == false { 
    self.delegate?.ApplyNowToSendBack() // delegate method 
    } 
} 

// Another Viewcontroller  
class ShortlistViewController: ParentViewController , QuizPopUpViewControllerDelegate { 

} 

,我得到以下錯誤:的ViewController不符合協議xyzDelegate

Type "ShortlistviewController" does not conform to protocol QuizPopUpViewControllerDelegate

+0

Hi Pravin。您可能想看看stackoverflow.com/help/how-to-ask並嘗試改進您的問題以獲得更多更好的答案。 – Flip

+0

當然,但我正在學習,如何使用Stackoverflow和Swift以及..你可以幫我解決我的問題 –

回答

0

的問題到底是什麼錯誤說明是在暗示。您需要讓您的班級符合QuizPopUpViewControllerDelegate代表。

爲此,您需要聲明函數,QuizPopUpViewControllerDelegate中的內容。

// Another Viewcontroller  
    class ShortlistViewController: ParentViewController , QuizPopUpViewControllerDelegate { 
      func ApplyNowToSendBack() { 
      // do something with the callback. 
      } 
    } 

爲了避免要求在今後這樣的問題,我會推薦閱讀更多關於delegate pattern in Swift

相關問題