我想在我的iOS應用程序(swift 2)中實現委託,但得到錯誤「從類'UIViewController'和'AppDelegate'的多繼承。我從一個空白的swift文件創建了一個新的MyAppDelegate,並得到了相同的錯誤(但是使用'MyAppDelegate')。對於MyAppDelegate.swift的代碼如下:iOS中的多繼承和AppDelegate(swift)
import Foundation
import MediaPlayer
class InstatunesAppDelegate {
}
我在這裏實現它,得到的錯誤:
class myViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, InstatunesAppDelegate {
我仍然試圖環繞代表我的頭......如何MyAppDelegate超類?如果我在AppDelegate中定義協議和委託,如何在其他類中調用它們?任何幫助表示讚賞。在此先感謝...
請解釋你如何嘗試使用代表。什麼想要使用委託,它會調用委託的功能?你使用協議來定義委託需要做什麼,然後一個類符合該協議。請注意,你不應該給應用程序委託額外的責任,它應該只是應用程序委託,沒有別的...... – Wain
在swift中沒有多重繼承。 'InstatunesAppDelegate'必須是一個協議。 – vikingosegundo
冒號後面的_first_項可以是一個類。其餘的必須是協議。 InstatunesAppDelegate是一個類,而不是協議。 – gnasher729