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

SOLVED: Day 57: No SceneDelegate.swift file

Forums > 100 Days of SwiftUI

Working on Day 57 and trying to save the list of Wizards. It says to make some changes to my SceneDelegate.swift file, but I don't have one. Is this something I'm supposed to create or is that a file added by an older version of Xcode?

Using Xcode 12.4 on Mac OS 10.15.7.

3      

Based on the note at the end of Day 58, the one-to-many lesson, I'm guessing the question I have above is no longer relevant. Looks like it may have been fixed in a version of Xcode after these tutorials were written.

3      

When you create a new XCode 12 App project you have the option to select a Life Cycle in the same window you provide a name for your project. If you do not have a SceneDelegate.swift file then it means you chose the SwiftUI App lifecycle that is new with XCode 12.

To get this file you would need to select the UIKit App Delegate lifecycle instead, which is what I did to follow along with the 100 days.

4      

Actually,I find the solution by myself,this is the best solution!!!!!!!

@Environment(\.managedObjectContext) var moc1

@FetchRequest(entity:Wizard.entity(),sortDescriptors:[]) var mywizard:FetchedResults<Wizard>

    func add1(){
        let movename1="天天"
        let wizard=Wizard(context: self.moc1)
        wizard.name=movename1

    }
    func save(){

           if  self.moc1.hasChanges {

               do{
                   moc1.mergePolicy=NSMergePolicy.mergeByPropertyObjectTrump
                   try self.moc1.save()

               }catch{
                   print("it cannot be saved")
               }
           }
    }

3      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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.