xcode - IOS Swift defining own app-settings in own class -
im new in swift , x-code. im searching way import own defined class (best case in own document). want store needed settings (text-snippets , app-settings) in file. example:
class snippetsandsettings { // e.g translations let t_welcome: string = "welcome app" let t_share: string = "social share buttons" let t_rate: string = "rate" // e.g settings let s_weburl: string = "http://www.mypage.com/webservice.php" let s_slider: bool = false let s_bgcolor: string = "#ff9900" let s_tcolor: string = "#222222" let t_shadow: string? // bool or colorstring! }
i want use class on every app-page. can not import for example in viewcontroller.swift
my questions:
- in format have save file (snippetsandsettings)? cocoa class
- how can import file in viewcontroller.swift
- is common way store own app-settings in swift?
the method store settings via nsuserdefaults
. can setup default values in app delegate's application:didfinishlaunchingwithoptions:
method. example:
nsuserdefaults.standarduserdefaults().registerdefaults([ "volume": 100, "showshadows": true ])
to these back, do:
nsuserdefaults.standarduserdefaults().integerforkey("volume")
and
nsuserdefaults.standarduserdefaults().boolforkey("showshadows")
for translations, should in internationalization , localization
Comments
Post a Comment