ios - Cannot invoke 'functionName' with an argument list of type '([(nameOfClass)])' in Swift xcode 6.3.1 -
im learning swift , having following problem please help..
i have 3 classes- tableviewcontroller broadcastmodel broadcastrequest following error (the line of error marked comment) cannot invoke 'requestfinished' argument list of type '([(broadcastmodel)])'
import uikit public class tableviewcontroller: uitableviewcontroller { var broadcasts = [broadcastmodel]() //mark: viewcontrollerlifecycle override public func viewdidload() { super.viewdidload() //maybe use 2d array sections of broadcasts.. broadcastrequest().requestnewbroadcasts() } public func requestfinished(requestedbroadcasts: [broadcastmodel]) { self.broadcasts = requestedbroadcasts \* here error *\ self.tableview.reloaddata() } public class broadcastrequest { func requestnewbroadcasts() { var broadcasts = [broadcastmodel]() ..... ..... broadcasts.append(broadcast) tableviewcontroller.requestfinished(broadcasts) } } public class broadcastmodel: nsobject, printable { let id: string let broadcasturl: string ... ... override public var description: string { return "id: \(id), url: \(broadcasturl) ....." } init(...) { ... } }
since using:
tableviewcontroller.requestfinished(broadcasts)
you should define function class function:
class func requestfinished(requestedbroadcasts: [broadcastmodel]) { self.broadcasts = requestedbroadcasts \* here error *\ self.tableview.reloaddata() }
recommend figure out difference between function , class function , difference between class , class instance
if want class instance, must have reference it, instead of having class name.
Comments
Post a Comment