user:[String: [String]] この型のデータを realm に保存したいのでこのコードを書きました
swift
1import UIKit 2import RealmSwift 3class userData: Object { 4 @objc dynamic var user:[String: [String]] = [:] 5} 6class ViewController: UIViewController { 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 let userfoo = userData() 11 userfoo.user = ["foo": ["bar", "baz"]] 12 let realm = try! Realm() 13 try! realm.write { 14 realm.add(userfoo) 15 } 16 } 17}
実行するとこのエラーが出ます
realm[10219:111656] *** Terminating app due to uncaught exception 'RLMException', reason: 'Property 'user' is declared as 'NSDictionary', which is not a supported RLMObject property type. All properties must be primitives, NSString, NSDate, NSData, NSNumber, RLMArray, RLMLinkingObjects, or subclasses of RLMObject. See https://realm.io/docs/objc/latest/api/Classes/RLMObject.html for more information.'
対処法を教えてください
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。