ios - Extra argument 'boolForKey' in call? -
i making things happen when app launches. put statement. returns error: extra argument 'boolforkey' in call.
i using swift.
how fixed?
code:
if nsuserdefaults.standarduserdefaults(boolforkey: "haslaunchedonce") { //app has launched before } else { nsuserdefaults.standarduserdefaults(setbool: true, forkey: "haslaunchedonce") nsuserdefaults.standarduserdefaults(synchronize) //first time launch }
how fixed?
it looks call should be:
if nsuserdefaults.standarduserdefaults().boolforkey("haslaunchedonce") {
that's because objective-c method name -boolforkey:
, not -standarduserdefaults:boolforkey:
. when translating swift, put first part of method name before left parenthesis, subsequent parts appearing inside parens.
Comments
Post a Comment