質åããããã¨ã§ããå¾ãããªããåçãã¢ããã¤ã¹ãããã15å調ã¹ã¦ãããããªããã¨ã¯ã質åãããï¼æ°è¦ç»é²ãã¦è³ªåãã¦ã¿ãã
çãããSwiftã§ã¬ãªã¬ãªéçºãã¦ã¾ããï¼ Objective-Cããå¤ããããã¦æ¶ç®ã«ãªããªããéçºãã¦ã¾ããã ãããªä¸ãã¼ã¿ç®¡çã«Swiftã§ãMagicalRecord使ãããã¨æã£ã¦ã¾ããã è¨èªãæ°ãããªã£ãäºã ããä½ã代ããããªãããªãã¨æ¢ãã¦ããã¨ãã Realmã«åºä¼ãã¾ããã å®éã«ä½¿ã£ã¦ã¿ãã®ã§ããã®ä½¿ç¨æããä¼ãã§ããã°ã¨æãã¾ãã ç°å¢ x-code 6.0 swift os:ios realm 0.83 Realmã¨ã¯ CoreDataãSQLiteã«å¤ãã次ä¸ä»£Mobileãã¼ã¿ãã¼ã¹ã¿ããã Androidã§ã使ããã®ã§ç§»æ¤ããã¨ãã«ã¤ã³ã¿ãã§ã¼ã¹ãçµ±ä¸ããã¦ã¦ç§»æ¤ããããããï¼ è©³ããç¥ãããæ¹ã¯ãããè¦ãã°ããã¨æãã¾ãã ãªãRealmãé¸ãã ã®ã iOSã¢ããªãä½ã£ã¦ãã¨ãã¾ã Androidã¢ããªããªãã£ããå¿ ãã¨è¨ã£ã¦ããã»ã© Androidã¢ã
ðã¾ããã â æ¸ãã¦ããã㨠Realmã«ææ¦ãã¦ã¿ãã®ã§ãç°¡åãªã¢ããªã®ä½ãæ¹ãã¡ã¢ ã¡ãªã¿ã«Realm=ã¬ã«ã ãããð â ä¸è¨ã®çç¶ã«å¹è½ãããã¾ã ã¨ãããããµã¯ãã¨Realm触ã£ã¦ã¿ãã ã¨ããããæä½éã®å®è£ ã§åºæ¬ãç解ããã â ãã®è¨äºã®ç¹å¾´ åå¿è ã§ãå 容ãåãããããããã«ãªã£ã¦ã¾ãã å¤æ°ã¯è±èªã§å½åããã®ãã»ãªãªã¼ã§ãããããã¦å ¨é¨æ¥æ¬èªã«ãã¦ã¾ãï¼ããã§ãåãã¾ãï¼ xcode 10.1 swift 4.2 (2019å¹´2æç¾å¨) â 主ãªæµã ããã¸ã§ã¯ãã®ä½æ cocoapodã§realmã追å ã¹ãã¼ãªã¼ãã¼ãã®è¨å® ã¢ãã«ã¯ã©ã¹ã®ä½æ ã»ã«ã¯ã©ã¹ã®ä½æ ViewControllerã®å®è£ å®æï¼ ð æ¬ç·¨ â¼ï¸ããã¸ã§ã¯ãã®ä½æ ã¨ããããSingleViewAppãé¸æ ä»åã®ãããã¯ããã¼ã ã¯ãTestRealmãã«ãã¾ãã â¼ï¸cocoaPodsã§Re
åèã¾ã§ã«ãä¸è¨ã®ã¢ãã«å®ç¾©ã¨ãã¼ã¿ç»é²ç¨ã®ã³ã¼ãã以ä¸ã«ç¤ºãã¾ãã /// é¸æã¢ãã« class Player: Object { // é¸æå @objc dynamic var name : String = "" // 身é·(åä½ï¼m) @objc dynamic var height : Double = 0.0 // ä½é(åä½ï¼kg) @objc dynamic var weight : Double = 0.0 } // ãã¼ã¿ç»é²ç¨ã³ã¼ãä¾ // 1人ç®ã®é¸æ let player1 = Player() player1.name = "HIRO" player1.height = 163.0 player1.weight = 60.5 // 2人ç®ã®é¸æ let player2 = Player() player2.name = "CHIHIRO" player2.h
æ¬è¨äºã§ã¯Realm Swiftã使ã£ã¦è¤æ°æ¡ä»¶ã§ã½ã¼ãããæ¹æ³ãç´¹ä»ãã¾ãã使ç¨ãã¦ããRealm Swiftã®ãã¼ã¸ã§ã³ã¯ v4.4.1 ã§ãã Realm Javaã§è¤æ°æ¡ä»¶ã®ã½ã¼ããããå ´åãRealm Javaã使ã£ã¦è¤æ°ã®æ¡ä»¶ã§ã½ã¼ã(並ã¹æ¿ã)ãã - é ¢ããï¼ãã®è¨äºãã覧ãã ããã Realm Swiftã使ã£ã¦è¤æ°ã®æ¡ä»¶ã§ã½ã¼ã(並ã¹æ¿ã)ãã ãã¨ãã° Userã¨ãããªãã¸ã§ã¯ãããããUserã¯ã©ã¹ã¯ä¸è¨ã®ããã«å®ç¾©ãã¦ããã¨ãã¾ãã import RealmSwift class User : Object { // ã¦ã¼ã¶ã¼ã®ID @objc dynamic var id: String = "" // ãªã³ã©ã¤ã³ç¶æ @objc dynamic var isOnline: Bool = false // ååã®ãªã³ã©ã¤ã³æå» @objc dynamic var
åæãã¼ã¿ã®ãããããå ¥ã£ãRealmã®ãã¡ã¤ã«ãç¨æãã¦ããã ã¢ããªã«çµã¿è¾¼ãã§ä½¿ãããã¨æã£ã¦ãã¾ãã ããã«ã¯ãã¼ã¿ãå ¥ã£ãDBã®ãã¡ã¤ã«ãå¿ è¦ã§ãã Realmã®ä¿åå ´æãç¹å®ããæ¹æ³ãã¡ã¢ãã¦ããã¾ãã åæ ç°å¢ã¯Xcode9.2ãSwift4.0ã使ç¨ãã¦ãã¾ãã åæãã¼ã¿ä½æç¨ã®Xcodeããã¸ã§ã¯ããä½ã£ã¦ããã¾ãã å®æ©ãã·ãã¥ã¬ã¼ã¿ã¼ã«Runãã¦ããã¾ãã åèãµã¤ãæ§ ãããã¨ããããã¾ãï¼ï¼ï¼ https://realm.io/docs/swift/latest/#copying-objects-between-realms How to find my realm file? - Stack Overflow ã·ãã¥ã¬ã¼ã¿ã¼ã«ã¤ã³ã¹ãã¼ã«ããå ´åã®å ´æ // DBã®ãã¡ã¤ã«ã®å ´æ print(Realm.Configuration.defaultConfig
æ¦è¦ Realm Databaseã«æ ¼ç´ãããã¼ã¿ãåå¾ããã«ã¹ã¿ã ã»ã«ã«è¡¨ç¤ºãããæ¹æ³ã«ã¤ãã¦ã®è¨äºã§ãã Realm Databaseã®ä½¿ãæ¹ã¨ã«ã¹ã¿ã ã»ã«ã®ä½ãæ¹ãå¦ãã ã®ã§çµã¿åããã¦ã¿ã¾ããã TableViewã®ã»ã«ãããªãã¦å¥½ããªå½¢ã®ã»ã«ã«ãã¼ã¿ã表示ãããï¼ã¨ãã£ãæ¹ã®ãå½¹ã«ç«ã¦ãã°å¹¸ãã§ãã å®è¡ç°å¢ ãXcodeã Version 10.1 ãSwiftã version 4.2.1 ãCocoaPodsãversion 1.6.0 ãRealm Databaseã 3.13.1 å®è£ Realm Databaseã®å°å ¥ ã¯ããã«Realm Databaseãæ°è¦ããã¸ã§ã¯ãã«å°å ¥ãã¾ããRealm Databaseã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã¯ä¸è¨è¨äºã大å¤åèã«ãªãã¾ãã®ã§ãã¡ãããåç §ãã ããã ãSwiftãRealmSwiftãã¤ã³ã¹ãã¼ã«(CocoaPods)ããå®è¡
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}