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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -