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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -