//
// ViewController.swift // 首选项数据读写 // // Created by mac on 15/7/12. // Copyright (c) 2015年 fangyuhao. All rights reserved. //import UIKit
class ViewController: UIViewController {
@IBOutlet weak var btnSave: UIButton!@IBOutlet weak var inputText: UITextView!@IBOutlet weak var outputText: UITextView!var ud:NSUserDefaults!override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. ud = NSUserDefaults.standardUserDefaults() if let value:AnyObject = ud.objectForKey("data"){ outputText.text = value as! String }else{ outputText.text = "No value" }}override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated.}@IBAction func btnSaveClicked(sender: AnyObject) { ud.setObject(inputText.text, forKey: "data") println("saved")}
}