swift - private func: Missing argument for parameter #1 in call -
well, here's 'missing argument parameter #1 in call' issue. (seems apple better job naming errors :-p )
in class, i'm calling private function libraryvisibility()
, , on line missing argument parameter #1 in call
error on compilation. don't understand why.
anyhow, here's code:
import cocoa @nsapplicationmain class appdelegate: nsobject, nsapplicationdelegate { var librarystate: bool = libraryvisibility() func applicationdidfinishlaunching(anotification: nsnotification) { … } private func libraryvisibility() -> bool { … // dostuff , return boolean return true } }
you can't call instance functions in default initialiser of property
you can either make libraryvisibility()
function class
function:
@nsapplicationmain class appdelegate: nsobject, nsapplicationdelegate { var librarystate : bool = appdelegate.libraryvisibility() private class func libraryvisibility() -> bool { let homeurl = nsurl(string: nshomedirectory()) let libraryurl = nsurl(string: "library", relativetourl: homeurl) return libraryurl!.hidden } }
or make librarystate
property lazy
property:
@nsapplicationmain class appdelegate: nsobject, nsapplicationdelegate { lazy var librarystate : bool = self.libraryvisibility() private func libraryvisibility() -> bool { let homeurl = nsurl(string: nshomedirectory()) let libraryurl = nsurl(string: "library", relativetourl: homeurl) return libraryurl!.hidden } }
the property initialised first time use it.
Comments
Post a Comment