Now I get error Property types for 'value' property do not match. Old type 'float', new type 'double'
How to clear database or migrate is successfully?
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- Realm migration from a required variable to nullab
相关文章
- Using if let syntax in switch statement
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
- How can I vertically align my status bar item text
- Adding TapGestureRecognizer to UILabel in Swift
- Attempt to present UIAlertController on View Contr
- Swift - Snapshotting a view that has not been rend
To completely delete the Realm file from disk and start from scratch, it's simply a matter of using
NSFileManager
to manually delete it.For example, to delete the default Realm file:
If you want to preserve the Realm file, but completely empty it of objects, you can call
deleteAll()
to do so:Update: I feel I neglected to mention this in my original answer. If you choose to delete the Realm file from disk, you must do so before you've opened it on any threads in your app. Once it's opened, Realm will internally cache a reference to it, which won't be released even if the file is deleted.
If you absolutely do need to open the Realm file to check its contents before deletion, you can enclose it in an
autoreleasepool
to do this.Have you tried
You could also try deleting the realm off the device by plugging it into the computer, going to Xcode and then Devices, and then finding the current realm there and deleting it.
Swift 4.2:
In addition to using
NSFileManager
to remove the file, also remove the.lock
file and.management
folder as well. Otherwise, if you try to recreate the realm file with the same name, it will give an error saying it can't find itThis is how to do in swift 4.1:
Whilst the other comments are right, you should really look at : https://realm.io/docs/swift/latest/#migrations
It gives a super clear explanation of how to do migration, and it's really simple, and far better deleting everything if it can be helped.