ios - func return does notReturn String from my conform to protocol StringLiteralConvertible error -


i have class has func of return path file:

func getarchivepathfor(filename: string!) -> string {         var paths = nssearchpathfordirectoriesindomains(.documentdirectory, .userdomainmask, true)[0] string              var path: string = paths.stringbyappendingpathcomponent(filename!)         return path         } 

but when try use in code like:

let val = helpers.getarchivepathfor("mylist.plist") 

i error: "return string func return not conform protocol stringliteralconvertible error". why so?

you declaring instance method, whereas helpers.getarchivepathfor("mylist.plist") calling class method.

if want declare class method, try prefix class:

class helpers {     class func getarchivepathfor(filename: string!) -> string {     ^^^^^ 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -