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
Post a Comment