Store global strings in iOS in Swift for app-wide use -


i designing app has login screen. when user enters username , password, call web service done returns token on successful login. need send token every http call inside different screens across app.

i want achieve similar functionality this: where store global constants in ios application?

as there won't .h , .m files in swift, how store these global strings (note these not constants, these global variables) need able access in view controller

this wanted: sharing strings , variables throughout ios app

i able share strings such apikeys, tokens using nsuserdefaults

saving:

nsuserdefaults.standarduserdefaults().setobject("apistringhere", forkey: "apikey") nsuserdefaults.standarduserdefaults().synchronize() 

getting:

nsuserdefaults.standarduserdefaults().objectforkey("apikey") 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -