Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class empMaster: Object {
- dynamic var empId:String = String()
- dynamic var empName:String = String()
- }
- class empMaster: Object {
- dynamic var empId:String = String()
- dynamic var empName:String = String()
- override class func primaryKey() -> String {
- return "empId"
- }
- }
- fatal error: 'try!' expression unexpectedly raised an error: Error Domain=io.realm Code=10 "Migration is required due to the following errors:
- - Primary Key for class empMaster has been added." UserInfo=0x7a628b00 {Error Code=10, NSLocalizedDescription=Migration is required due to the following errors:
- - 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
- let config = Realm.Configuration(deleteRealmIfMigrationNeeded: true)
- Realm.Configuration.defaultConfiguration = config
- let config = Realm.Configuration(schemaVersion: 1) // 既存のファイルより大きな値ならなんでもいい
- Realm.Configuration.defaultConfiguration = config
- let config = Realm.Configuration(schemaVersion: 1, migrationBlock: { (migration, oldSchemaVersion) in
- // データ移行の処理を書く
- // 今回の場合は、プライマリキーの重複があれば解消する
- })
Add Comment
Please, Sign In to add comment