iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 23
0
Mobile Development

IOS App開發學習日誌系列 第 23

D23 Realm(二)

今天要進入實作的部分
首先先在AppleStore將RealmBrowser下載下來
https://ithelp.ithome.com.tw/upload/images/20191009/201209804ePPlCG2kT.png
載下來後先開啟縮小視窗放在旁邊,稍後會使用到這個軟體用來檢視資料庫的資料表內容
接著昨天的專案繼續,先在storyboard拉好三個textField跟一個送出的button
https://ithelp.ithome.com.tw/upload/images/20191009/20120980ubtetsHKVj.png
並在viewController中拉好元件的@IBOutlet跟@IBAction,並將textField做好delegate
https://ithelp.ithome.com.tw/upload/images/20191009/20120980kKywTUJzFz.png
接下來在寫入資料表的button func中寫入以下程式碼
https://ithelp.ithome.com.tw/upload/images/20191009/20120980mnzb8RS0lw.png
將app build起來後按下寫入按鍵後即可將資料寫入Realm
https://ithelp.ithome.com.tw/upload/images/20191009/20120980usyFA3PLyH.png
我們在程式碼中有將資料庫的位置print出來所以編譯器會顯示所在位置
https://ithelp.ithome.com.tw/upload/images/20191009/20120980o1H02hq4Bb.png
將路徑複製後在Finder的前往檔案夾位置貼上到所在路徑
https://ithelp.ithome.com.tw/upload/images/20191009/20120980MM4Rub0JXy.png
開啟default.realm
https://ithelp.ithome.com.tw/upload/images/20191009/20120980oh78i6SAxO.png
點選後allow後即會出現資料庫的內容,上面應該會有剛剛在textField輸入的數值
https://ithelp.ithome.com.tw/upload/images/20191009/20120980adKvUYhWGg.png


上一篇
D22 Realm(一)
下一篇
Day24 SwiftUI簡介
系列文
IOS App開發學習日誌30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言