Open Setting from your iOS application


Step 1.  Add a method in AppDelegate

private func setSettings() {

        let userDefaults = NSUserDefaults.standardUserDefaults()

        let defaults = [ “AppTitle” : “SettingLinker” ]

        userDefaults.registerDefaults(defaults)

        userDefaults.synchronize()

        println(userDefaults.dictionaryRepresentation())

    }

Step 2. Call this function from didFinishLaunchingWithOptions

    setSettings()

Step 3. Add a setting bundle

            Application —> New file —> Resources —> Setting Bundle

******** it will be a pre defined bundle . Change title according to your requirement.

Step 4. Add a Notification to trace changes of setting in Your ViewController’s ViewDidLoad method

override func viewDidLoad() {

        super.viewDidLoad()

        

        NSNotificationCenter.defaultCenter().addObserver(self,   selector: “traceChanges, name: NSUserDefaultsDidChangeNotification, object: nil)

        setupView()

        // Do any additional setup after loading the view, typically from a nib.

    }

Step 5. Add a method named  traceChanges .

func defaultsChanged() {

        setupView()

    }

Step 6. Add a new Method name  setupView

private func setupView() {

        let userDefaults = NSUserDefaults.standardUserDefaults()

        yourLabelL.text = userDefaults.stringForKey(“AppTitle”)

    }

Step 7. Add a button and addEvent Listener

@IBAction func gotoSetting(sender: AnyObject) {

        UIApplication.sharedApplication().openURL(NSURL.URLWithString(UIApplicationOpenSettingsURLString))

    }

Best Of luck..

enjoy coding

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: