Reputation:
I'm having trouble returning a variable from a 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
Upvotes: 3
Views: 2021
Reputation: 52143
dd()
seems to be a class method so you should prepend class
to the method signature.
class func dd() -> NSString {
...
}
Besides, please note that ;
at the end of each expression/assignment is totally optional so you can simply skip it.
Since your method doesn't return an implicitly unwrapped optional
, you should also delete !
too.
var test: NSString = SearchVC.dd()
Upvotes: 3