Realm Japan meetup #11

Realm Japan meetup #11

Realmのアーキテクチャ
- 遅延ロード・ゼロコピーの図解
- クエリがどのように実行されるか

9bf923e39671cde83584e3e926296c13?s=128

Kishikawa Katsumi

July 24, 2016
Tweet

Transcript

  1. Realm Japan Meetup #11

  2. #realm_jp

  3. https://github.com/kishikawakatsumi/ kishikawa katsumi http://kishikawakatsumi.hatenablog.com/ Realm

  4. Realm Objective-C/Swift 0.97.1 ˖ 'JYDSBTIFTXIFOBO3-.3FBMNJTEFBMMPDBUFEGSPNUIF XSPOHUISFBE ˖ *OEFYJOH#00-#PPMBOE/4%BUFQSPQFSUJFTBSFOPX TVQQPSUFE ˖

    4XJGU"EETVQQPSUGPSJOEFYJOHPQUJPOBMQSPQFSUJFT
  5. Realm Objective-C/Swift 0.98.0ʢ༧ఆʣ ˖ "TZOD2VFSJFT

  6. Realm Objective-C/Swift 0.99.0ʢ༧ఆʣ ˖ 'JOFHSBJOFE/PUJDBUJPO

  7. Realmͷ஗ԆϩʔυΛ׆༻͢Δʹ͸

  8. Realmͷجຊతͳ࢖͍ํ

  9. class Article: Object { dynamic var id: Int = 0

    dynamic var title: String = "" dynamic var content: String = "" dynamic var creationDate: NSDate = NSDate() dynamic var modificationDate: NSDate = NSDate() dynamic var deletionDate: NSDate? = nil dynamic var user: User? = nil let comments = List<Comment>() override static func primaryKey() -> String? { return "id" } } class Comment: Object { dynamic var id: Int = 0 dynamic var content: String = "" dynamic var user: User? = nil override static func primaryKey() -> String? { return "id" } } class User: Object { dynamic var id: Int = 0 dynamic var name: String = "" override static func primaryKey() -> String? { return "id" } }
  10. let realm = try! Realm() let article = Article() article.title

    = titleTextfield.text article.contents = contentTextfield.text let currentUser = realm.objectForPrimaryKey(User.self, key: userID) article.user = currentUser try! realm.write { in realm.add(article) }
  11. let realm = try! Realm() let articles = realm.objects(Article).filter("user =

    %@", currentUser) let article = articles[0]
  12. let realm = try! Realm() let currentUser = realm.objectForPrimaryKey(User.self, key:

    userID) try! realm.write { in currentUser.name = "..." }
  13. ஗ԆϩʔυΛ׆༻͢Δ

  14. override func viewDidLoad() { ... articles = realm.objects(Article).filter("user = %@",

    currentUser) } override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return articles.count } override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("", forIndexPath: indexPath) let article = articles[indexPath.row] cell.title = article.title cell.content = article.content cell.username = article.user.name return cell }
  15. ஗Ԇϩʔυͷ࢓૊Έ

  16. ஗Ԇϩʔυͷ࢓૊Έ articles = realm.objects(Article).filter("user = %@", currentUser)

  17. ஗Ԇϩʔυͷ࢓૊Έ articles = realm.objects(Article) .filter("user = %@", currentUser)

  18. ஗Ԇϩʔυͷ࢓૊Έ let allArticles = realm.objects(Article) let articles = allArticles.filter(“user =

    %@", currentUser)
  19. ஗Ԇϩʔυͷ࢓૊Έ let allArticles = realm.objects(Article) let articles = allArticles.filter(“user =

    %@", currentUser) 3FTVMUT"SUJDMF 5BCMF"SUJDMF
  20. ඇಉظΫΤϦ (Swift) let allArticles = realm.objects(Article) let articles = allArticles.filter(“user

    = %@", currentUser) 3FTVMUT"SUJDMF 5BCMF"SUJDMF 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS
  21. ඇಉظΫΤϦ (Swift) let articles = allArticles.filter(“user = %@", currentUser) let

    count = articles.count 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX
  22. ඇಉظΫΤϦ (Swift) let count = articles.count let article = articles[0]

    3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX "SUJDMF 3PX*OEFY 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX
  23. ඇಉظΫΤϦ (Swift) let article = articles[0] let title = article.title

    "SUJDMF 3PX*OEFY 3FTVMUT"SUJDMF 5BCMF"SUJDMF 2VFSZVTFS $PVOU 7JFX "SUJDMF 3PX*OEFY 5JUMF(FUUFS 3FBMN 4USJOH 5JUMF
  24. None
  25. IUUQTUFDICPPTUFSCPPUIQN

  26. Where to find us • # Realm Japan User Group:

    facebook.com/groups/realmjp • # Twitter: twitter.com/realmJapan • GitHub: github.com/realm • # StackOverflow: ja.stackoverflow.com/questions/tagged/realm • # Email: help@realm.io • # Slack: slack.realm.io/
  27. Realm Japan User Group # facebook.com/groups/realmjp

  28. Public Realm Slack # slack.realm.io/

  29. Official Twitter/Facebook twitter.com/realm facebook.com/655569387879379

  30. Official Web site # realm.io/jp

  31. Next Realm Meetup

  32. http://bit.ly/RealmJP_11 ୹͍Ξϯέʔτʹ͝ڠྗ͍ͩ͘͞