Saturday, 15 May 2010

xcode - IOS Swift defining own app-settings in own class -


The new IM in Swift and the X-code is one way to define its own class (the best case in one's own document) I'm looking to import I want to store all the required settings (text-snippets and app-settings) in this file. For example:

  class snippets and settings {// eg translated t_welcome: string = "Welcome to my app" t_share: string = "social share button" t_rate: string = "rate "/ Example setting s_weburl: string =" http://www.mypage.com/webservice.php "let's s_slider: bool = false let's s_bgColor: string =" # ff9900 "let's s_tColor: string =" # 222222 "t_shadow Come on: string? // Boole or color string! }  

I want to use this class on every app-page. But for example I can not import into ViewController.swift

My question:

  1. In what format do I want to save the file (snippets and settings)?
  2. How can I import a file into my ViewController? Swift
  3. Is there a common way to store self-app settings in Swift?

How to store settings. You can set your default value in the application: didFinishLaunchingWithOptions: method of your app representative. For example:

  NSUserDefaults.standardUserDefaults (). RegisterDefaults (["Volume": 100, "showShadows": true])  

To bring these back, you will:

NSUserDefaults.standardUserDefaults (). For translation, you should see for IntegerForKey ("Quantity")

and

NSUserDefaults.


No comments:

Post a Comment