swift - Function call is requiring an argument but the function takes no arguments -


i have code in file called makerequest.swift in class makerequest:

class makerequest {     func callapi () {         let url = nsurl(string: "http://apiserver.com)          let task = nsurlsession.sharedsession().datataskwithurl(url!) {(data, response, error) in             println(nsstring(data: data, encoding: nsutf8stringencoding))         }          task.resume()     } } 

and call makerequest.callapi(). however, requiring argument:

missing argument parameter #1 in call

when tried configure callapi take string:

class makerequest {     func callapi(urlend: string) {         ...     } } 

and call with

makerequest.callapi("ending") 

it errors with

cannot invoke 'callapi' argument list type of '(string)'

sorry how confusing swift's error messages are. (there cool reason nature of error message, never mind right now.) problem calling method class method declared instance method.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -