Swift3 從入門到精通Day29:Core Data

Alice
Alice
Jul 29, 2017 · 3 min read

日期:7/29(六)

學習內容:core data

左圖要產生實體myController才能拿他的屬性 右圖在let加上static func前加class就可以直接拿到他的屬性
這種不產生實體直接取得屬性的方法叫做singleton

singleton設計模式:程式裡唯一的實體


建立一個新的專案Use Core Data
手動建立userName passWord後 點選User確認Codegen為Class Definition

新增資料

先儲存資料
顯示資料

修改程式碼

HanHan第一個密碼就變成87654321了!

如果想修改但資料很多不知道是哪一筆怎麼辦?:用名字當索引

用名字當索引
密碼就便1314520了

刪除資料

在次呼叫資料就會發現已經被刪除了

這樣就學到core data的新增修改刪除資料!

Daily Swift

Hi, I’m Alice. :-]

Alice

Written by

Alice

Swift addict, Taipei|wl02722691@gmail.com

Daily Swift

Hi, I’m Alice. :-]

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade