Skip to content

Ensuring initialize has returned before attempting queries. #167

Answered by cbaker6
project-saf asked this question in Q&A
Discussion options

You must be logged in to vote

PR 168 won't fix your crash. To address your issue, you will have to make a change to your code to prevent the crash as the fix that needs to be made is a breaking change to the SDK. You need to do the following:

func fetch() async throws {
        // Insert these lines to delay for 1 second, if you still see an issue, increase the delay
        let nanoSeconds = UInt64(1 * 1_000_000_000)
        try await Task.sleep(nanoseconds: nanoSeconds)

        let staff = Staff(objectId: "someObjectID")
        let slip = try await Payslip.query("staff_" == staff).first()
}

The problem is you are using the old appDelegate lifecycle and your viewDidLoad is being called before the Swift SDK finishes…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@cbaker6
Comment options

@project-saf
Comment options

@cbaker6
Comment options

@cbaker6
Comment options

Answer selected by cbaker6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants