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:

  1. in format have save file (snippetsandsettings)? cocoa class
  2. how can import file in viewcontroller.swift
  3. 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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -