SIGABRT on Swift 1.2let realm=Realm()

Asked 2 years ago, Updated 2 years ago, 48 views

Nice to meet you.
I am studying the development of iOS apps by Swift personally.

Use the SDK in GoogleMap to count the distance traveled from a point
We are currently implementing a feature to store in history.
I'm trying to use Realm to store that historical data.

In the application, SIGABRT will be printed in the following code and will end.

Please tell me the wrong part.

inport UIKit
import GoogleMaps
import Spring
import RealmSwift

class Record:Object {
    dynamic var distance = Double()
    dynamic var average = Double()
    dynamic var createdDate=Double()
}

classGMapViewController:BaseViewController, CLLocationManagerDelegate{
    //     abbreviation
    @ IBAction override funconClickSpButton (sender: SpringButton) {
        // Save data when button is pressed
        let myRecord=Record()
        myRecord.distance=sumDistance
        myRecord.average=0.0
        myRecord.createdDate=NSDate().timeIntervalSince1970
        let realm = Realm() // Error here
        realm.beginWrite()
        realm.add (myRecord)
        realm.commitWrite()
    }
}

swift realm

2022-09-30 14:30

1 Answers

There is no problem with this code.
I understand that there is an error when initializing Realm, so I think the setup is wrong.

How did you set up Realm?

If you are using the framework downloaded from the website, check if it is set to Embedded Binaries below.

Dynamic Framework is dynamically linked and should be included in the application.

Enter a description of the image here


2022-09-30 14:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.