iOS Settings Bundle – Let Users Save Their Preferences via the iOS Settings App

With this video tutorial I am going to share with you how to create and use the iOS Settings bundle to let users of our mobile app be able to specify their user preferences via the iOS Settings app.

Settings App Screenshot

iOS Bundle Settings

The video tutorial below will cover:

  • Create and add the iOS Settings bundle file to our Xcode project
  • Configure the Root.plist file to display needed user interface components in iOS Settings app for user to be able to provide their preferences
  • Read and set user preferences in Swift code

Implementing iOS Settings Bundle – Video Tutorial

Reading User Preferences – Swift Code

import UIKit

class ViewController: UIViewController {
 
    override func viewDidLoad() {
        super.viewDidLoad()
  
        UserDefaults.standard.register(defaults: [String : Any]())
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // Read value of TextField with an identifier "name_preference"
        let userDefaults = UserDefaults.standard
        let userName = userDefaults.string(forKey: "name_preference")
        print("User name = \(userName)")
    }
 
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
 
}

I hope this short video tutorial was helpful to you! Also, please check out Swift Code Examples section for many short Swift code snippets you can use in your iOS apps.

Happy learning!

  • Igor Gorodnikov

    Thanks for your tutorial!) Could you explain a few moments: is
    — it possible in IOS 10 open General settings instead your own.
    — if I have extension like content blocker, can I redirect user to the Safari settings?