UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Core Data iPad: crash after deleting the NSManagedContextObject of the detailView

Forums > SwiftUI

I've made an app with Core Data, using a NavigationLink to load the DetailView on iPad. The view is set in the NavigationLink where the Task is set (@State private var task: Task). The classes for the Task where created and the ? (optional) was removed.

Everything works fine. I can add, edit and delete tasks in the MasterView, and there is no problem what so ever. Only when I delete the selected view of the MasterView, the app will crash. This is of course because the object doesn't exist anymore, and the detailView wants to render the view.

I've tried multiple ways to get info to correctly update the detailView... but nothing seems to work.

Any ideas how to do it?

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.