Missing argument for parameter # 1 when calling the function
I'm having trouble returning a variable from func
:
class SearchVC: UITableViewController, UISearchResultsUpdating, UISearchControllerDelegate {
var test: NSString = SearchVC.dd()!
func dd() -> NSString {
let testing: NSString = "d"
return testing
}
}
Error: missing argument for parameter #1 in call
+3
user5130344
source
to share
1 answer
dd()
is represented by a class method, so you must add class
to the method signature.
class func dd() -> NSString {
...
}
Also, note that ;
at the end of each expression / assignment is completely optional, so you can just skip it.
Since your method does not return implicitly unwrapped optional
, you must delete as well !
.
var test: NSString = SearchVC.dd()
+3
source to share