GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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      

Hacking with Swift is sponsored by try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

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.