標籤:
iCloud雲端儲存
1 import UIKit 2 3 class ViewController: UIViewController { 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 /** 8 1:可以儲存兩種 9 //IOS可識別的文檔10 11 //字典對象12 */13 14 // 2: Ubiquity Container............資料區域15 16 17 /**18 3:19 分成多個檔案小塊20 主動請求同步21 */22 23 //擷取資料24 var iCouldStore = NSUbiquitousKeyValueStore.defaultStore()25 iCouldStore.synchronize()26 27 28 //讀取29 iCouldStore.stringForKey("name")30 iCouldStore.stringForKey("area")31 32 println("name: \(name)")33 println("area: \(area)")34 35 36 37 //寫資料38 var iCouldStore = NSUbiquitousKeyValueStore.defaultStore()39 iCouldStore.synchronize()40 41 iCouldStore.setString(companyName, forKey: "name")42 iCouldStore.setString(companyArea, forKey: "area")43 44 45 }46 47 override func didReceiveMemoryWarning() {48 super.didReceiveMemoryWarning()49 50 51 }52 53 54 }
iOS開發——資料持久化Swift篇&iCloud雲端儲存