Guest User

Untitled

a guest
Sep 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. class empMaster: Object {
  2. dynamic var empId:String = String()
  3. dynamic var empName:String = String()
  4. }
  5.  
  6. class empMaster: Object {
  7. dynamic var empId:String = String()
  8. dynamic var empName:String = String()
  9.  
  10. override class func primaryKey() -> String {
  11. return "empId"
  12. }
  13. }
  14.  
  15. fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=10 "Migration is required due to the following errors:
  16. - Primary Key for class empMaster has been added." UserInfo=0x7a628b00 {Error Code=10, NSLocalizedDescription=Migration is required due to the following errors:
  17. - Primary Key for class empMaster has been added.}: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-800.0.46.2/src/swift/stdlib/public/core/ErrorType.swift, line 178
  18.  
  19. let config = Realm.Configuration(deleteRealmIfMigrationNeeded: true)
  20. Realm.Configuration.defaultConfiguration = config
  21.  
  22. let config = Realm.Configuration(schemaVersion: 1) // 既存のファイルより大きな値ならなんでもいい
  23. Realm.Configuration.defaultConfiguration = config
  24.  
  25. let config = Realm.Configuration(schemaVersion: 1, migrationBlock: { (migration, oldSchemaVersion) in
  26. // データ移行の処理を書く
  27. // 今回の場合は、プライマリキーの重複があれば解消する
  28. })
Add Comment
Please, Sign In to add comment