Post

Replies

Boosts

Views

Activity

Invalid Swift Support error
I've been working on my app, and I've been recently uploading version 2.0 builds to testflight. All was going well until now, where I can run the app in xcode, but can't publish to app store connect because of the error: "Invalid Swift Support. The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it." Any help is appreciated.
0
0
272
Sep ’24
CloudKit Web Services with ASP.NET Core server to server key auth
Hello, I have an iOS app that is still in development, and I am also making a website for it with asp.net core. I am trying to use a server to server key, but it isn't working. The response is: { "uuid" : "some_uuid", "serverErrorCode" : "AUTHENTICATION_FAILED", "reason" : "Authentication failed" } I am using a library called EllipticCurve. You can find it here. My code is: var requestData = new { zoneID = new {}, query = new { recordType = "CD_Person", filterBy = new [] { new { comparator = "EQUALS", fieldName = "CD_email", fieldValue = new { value = email, type = "String" } } }, sortBy = new [] { new { fieldName = "CD_email" } } }, zoneWide = "true", numbersAsStrings = "true" }; string request = JsonSerializer.Serialize(requestData); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("X-Apple-CloudKit-Request-KeyID", "my_key_id"); DateTime date = DateTime.Now; string iso8601Date = date.ToUniversalTime().ToString("u").Replace(" ", "T"); client.DefaultRequestHeaders.Add("X-Apple-CloudKit-Request-ISO8601Date", iso8601Date); byte[] bytes = Encoding.UTF8.GetBytes(request); SHA256 hashstring = SHA256.Create(); byte[] hash = hashstring.ComputeHash(bytes); string base64Request = Convert.ToBase64String(hash); string paramsToSign = $"{iso8601Date}:{base64Request}:my url"; PrivateKey privateKey = PrivateKey.fromPem("-----BEGIN EC PRIVATE KEY-----\nprivate_key\n-----END EC PRIVATE KEY-----"); Signature signature = Ecdsa.sign(paramsToSign, privateKey); client.DefaultRequestHeaders.Add("X-Apple-CloudKit-Request-SignatureV1", signature.toBase64()); var content = new StringContent(request, Encoding.UTF8, "application/json"); var response = client.PostAsync("https://api.apple-cloudkit.com/database/1/my_container/development/public/records/query", content); string responseString = response.Result.Content.ReadAsStringAsync().Result; Console.WriteLine(responseString); return View(); Any help would be appreciated.
0
0
471
Jan ’24
Memory leak in watchOS app
I have been working on an watchOS version of my iOS app using SwiftData. I have a TabView and on one of the views there is a plus button in the bottom bar. It contains a navigation link. When I tap it for some reason two of the views are stacked and I have to click the back button twice to pop both. After that, when I navigate to another view in the TabView, the app freezes. I checked this in instruments and apparently in "All heap and Anonymous VM" and also "All heap allocations" it is generating hundreds of thousands of objects with category "Malloc 32 bytes" and responsible library "libswiftCore.dylib" and responsible caller "swift_allocObject." This is happening every second, all while the app is frozen. The body of the file that includes the plus button(only watchOS): List(sessions) { session in HStack { VStack { HStack { if session.selected == false { Text(session.name ?? "no name") } else { Text(session.name ?? "no name") .font(.system(size: 12)) Text("(Selected)") .font(.system(size: 12)) } Spacer() } Spacer() HStack { Text(session.cube ?? "no cube") Spacer() } } Spacer() if session.cube == "3x3" { Image(systemName: "square.grid.3x3") .font(.title2) } else if session.cube == "2x2" { Image(systemName: "square.grid.2x2") .font(.title2) } else { Image("4x4") .font(.title2) } } .contentShape(Rectangle()) .onTapGesture { if selectedSession.count >= 1 { if session.selected == true { return } else { withAnimation { selectedSession[0].selected = false usleep(100000) session.selected = true } } } else { withAnimation { session.selected?.toggle() } } } } .navigationTitle("Sessions") .toolbar { ToolbarItemGroup(placement: .bottomBar) { Spacer() NavigationLink { AddSessionView() } label: { Image(systemName: "plus") } } } (Remember that this is only occurring on watches) The body of the file that the plus button goes to: ScrollView { VStack { TextField("Name", text: $name) .font(.caption) .frame(maxHeight: 50) Picker("Cube", selection: $cube) { ForEach(cubes, id: \.self) { cube in Text(cube) } } .onChange(of: cube) { getImage() } .frame(minHeight: 50) Button("Create") { if name != "" { if cube == "Playground" { playground = true cube = "3x3" } let session = Session(name: name, cube: cube, image: image, pinned: false, selected: false, playground: playground) modelContext.insert(session) if playground { playground = false } dismiss() } } } } The getImage() function that the onChange calls: private func getImage() { switch cube { case "3x3": image = "square.grid.3x3" case "2x2": image = "square.grid.2x2" case "4x4": image = "4x4" default: print("this will never execute") image = "square.grid.3x3" } } Any help appreciated.
0
0
653
Sep ’23
Query encountered an error: SwiftData.SwiftDataError(_error: SwiftData.SwiftDataError._Error.unsupportedPredicate) swiftdata
I am working on a SwiftData app, and when I query any of the ones with the Predicate (NOT Predicate) I get Query encountered an error: SwiftData.SwiftDataError(_error: SwiftData.SwiftDataError._Error.unsupportedPredicate). The code for my file is below. import SwiftData import SwiftUI struct timeListView: View { @Environment(\.modelContext) var modelContext @Query(sort: \Time.date, order: .reverse) var times: [Time] @Query(filter: #Predicate<Time> { time in time.unfortime! < 6000 }, sort: \Time.date, order: .reverse) var timesSub60: [Time] @Query(filter: #Predicate<Time> { time in time.unfortime! < 3000 }, sort: \Time.date, order: .reverse) var timesSub30: [Time] @Query(filter: #Predicate<Time> { time in time.unfortime! < 2000 }, sort: \Time.date, order: .reverse) var timesSub20: [Time] @Query(filter: #Predicate<Time> { time in time.unfortime! < 1000 }, sort: \Time.date, order: .reverse) var timesSub10: [Time] @Query(filter: #Predicate<Time> { time in time.unfortime! < 500 }, sort: \.date, order: .reverse) var timesSub5: [Time] @Query(sort: \Time.date, order: .forward) var timesOldest: [Time] @Query(sort: \Time.unfortime, order: .forward) var timesBest: [Time] @Query(filter: #Predicate<Session> { session in session.selected == true }) var selectedSession: [Session] @State var forTime: String = "" @State var formattedTimes: [String] = [] @State var sort: [Time] = [] @Binding var showDate: Bool private var columns: [GridItem] { return [ .init(.adaptive(minimum: 85, maximum: 85)) ] } // format date and display var body: some View { NavigationStack { VStack { HStack { if showDate { showDateList() } else { noDateList() } } Spacer() } .toolbar { ToolbarItem { Menu { Section("Sort") { Button("Newest") { sort = times } Button("Best") { sort = timesBest } Button("Oldest") { sort = timesOldest } Button("Sub 60") { sort = timesSub60 } Button("Sub 30") { sort = timesSub30 } Button("Sub 20") { sort = timesSub20 } Button("Sub 10") { sort = timesSub10 } Button("Sub 5") { sort = timesSub5 } } } label: { Label("Menu", systemImage: "line.3.horizontal.decrease.circle") } .menuOrder(.fixed) } } .navigationTitle("Times") } } private func getDate(time: Time) { let date = time.date! let calendar = Calendar.current let hour = calendar.component(.hour, from: date) let minute = calendar.component(.minute, from: date) let second = calendar.component(.second, from: date) let timeToFormatComponents = DateComponents(calendar: calendar, year: calendar.component(.year, from: date), month: calendar.component(.month, from: date), day: calendar.component(.day, from: date), hour: hour, minute: minute, second: second) let timeToFormat = timeToFormatComponents.date! let formatter = DateFormatter() formatter.dateFormat = "M/dd/yy', 'h:mm a" forTime = formatter.string(from: timeToFormat) } @ViewBuilder func showDateList() -> some View { List { ForEach(sort) { time in if time.session == selectedSession[0] { NavigationLink(destination: timeDetailView(time: time)) { HStack { Text(time.time!) .onAppear { getDate(time: time) time.formatted = forTime } Spacer() Text(time.formatted!) }.swipeActions { Button("Delete", role: .destructive) { modelContext.delete(time) } } } .buttonStyle(.plain) } } } .onAppear { sort = times } } @ViewBuilder func noDateList() -> some View { LazyVGrid(columns: columns, spacing: 0) { ForEach(sort) { time in if time.session == selectedSession[0] { NavigationLink(destination: timeDetailView(time: time)) { TimeBoxView(time.time ?? "Not Found") .frame(minWidth: 100) .padding() .onAppear { getDate(time: time) time.formatted = forTime } } .buttonStyle(.plain) } } } .onAppear { sort = times } } } #Preview { timeListView(showDate: .constant(true)) .modelContainer( for: [Time.self]) } Any help appreciated.
0
0
807
Aug ’23
How to setup SwiftData in a Widget
So I have been trying to add a widget to my app. I am trying to add SwiftData to sync data from my app to the widget. My attempt at doing that is shown below: import SwiftData import SwiftUI import WidgetKit @main struct CubeSpeedWidgetBundle: WidgetBundle { let fullSchema = Schema([Time.self, Session.self]) let configuration = ModelConfiguration(schema: Schema([Time.self, Session.self]), inMemory: false, readOnly: false, cloudKitDatabase: .automatic) var body: some Widget { CubeSpeedWidget() .modelContainer(try! ModelContainer(for: fullSchema, configurations: [configuration])) CubeSpeedWidgetLiveActivity() } } Xcode says that "Value of type 'CubeSpeedWidget' has no member 'modelContainer'". How should I do this properly? Thanks.
1
0
1.8k
Jul ’23
dyld symbol not found
I just updated to Xcode 15 beta 5, and just tried to run my project(macOS). It uses swift data, and it builds fine. When I run it, I get the runtime error: dyld[89450]: Symbol not found: _$s10Foundation9PredicateVyACyxxQp_QPGqd__AA0B11ExpressionsO8VariableVy_xGxQpXEcAA08StandardB10ExpressionRd__Sb6OutputRtd__lufC Referenced from: <8C04CB76-2231-349A-965F-16640BD2A139> /Users/my_username/Library/Developer/Xcode/DerivedData/ExternalCubeSpeed-cwevolpyjplwhrcsekahxoypgxuy/Build/Products/Debug/CubeSpeed.app/Contents/MacOS/CubeSpeed Expected in: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation This was not happening with Xcode 15 beta 4. My Mac is running macOS 14 public beta. Thanks for any help.
1
5
1.3k
Jul ’23
Timer running at increased speed each time I start it again
I am currently working on an app, and it has a timer in a separate view from the main ContentView(). I have realized that I am not resetting the timer each time, and since it is initialized with a binding var, the var is increasing faster than desired (add one to var every 0.01 seconds). Simply setting the var to a binding and changing it that way hasn't worked for some reason, and I have created a function that runs every time the timer fires to check if the isRunning binding var is false, and if it is, invalidate the timer. The code for ContentView is: import Foundation import SwiftUI import CoreData struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest(entity: Time.entity(), sortDescriptors: []) private var times: FetchedResults<Time> @State var startstop: String = "Start" @State var start: Bool = false @State var elapsedTime: Int = 0 @State var timeMinutes: Int = 0 @State var timeSeconds: Int = 0 @State var timeMilliseconds: Int = 0 @State var hour: Int = 0 @State var minute: Int = 0 @State var second: Int = 0 @State var formattedTime: String = "" @State var saveTime: Int = 0 @State var timerRunning: Bool = true @State var firstRun: Bool = true // Format date after core data fetch to allow creating NSSortDescript for date var body: some View { VStack{ Text("Cube App") .font(.largeTitle) .fontWeight(.bold) .padding(.top, 4.0) Text(scrambles.randomElement()!) .font(.title) .fontWeight(.semibold) .multilineTextAlignment(.center) .padding([.top, .leading, .trailing]) if start{ Stopwatch(progressTime: $elapsedTime, isRunning: $timerRunning) .padding(.top) .fontWeight(.bold) .onAppear{ timerRunning = true toggleStartStop() } } Button(startstop){ toggleStart() if start == false{ saveTime = elapsedTime stopTime() elapsedTime = 0 toggleStartStop() } } .fontWeight(.bold) .font(.system(size: 30)) .padding(.top, 30) Spacer() } } private func stopTime(){ timerRunning = false print(saveTime) addTime() } private func addTime(){ withAnimation{ timeMinutes = saveTime / 6000 timeSeconds = (saveTime % 6000) / 100 timeMilliseconds = saveTime % 100 let time = Time(context: viewContext) if timeMinutes == 0{ if timeMilliseconds < 10{ time.time = "\(timeSeconds).0\(timeMilliseconds)" }else{ time.time = "\(timeSeconds).\(timeMilliseconds)" } }else if timeMilliseconds < 10{ if timeSeconds < 10{ time.time = "\(timeMinutes):0\(timeSeconds).0\(timeMilliseconds)" }else{ time.time = "\(timeMinutes):\(timeSeconds).0\(timeMilliseconds)" } }else{ if timeSeconds < 10{ time.time = "\(timeMinutes):0\(timeSeconds).\(timeMilliseconds)" }else{ time.time = "\(timeMinutes):\(timeSeconds).\(timeMilliseconds)" } } time.date = Date() saveContext() } } private func saveContext(){ do { try viewContext.save() } catch { let error = error as NSError print(error) fatalError(error as! String) } } private func toggleStart(){ if start{ start = false }else{ start = true } } private func toggleStartStop(){ if startstop == "Start"{ startstop = "Stop" }else{ startstop = "Start" } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { let persistenceController = PersistenceController.shared ContentView().environment(\.managedObjectContext, persistenceController.container.viewContext) } } Note: I have excluded the array of "scrambles" as it went over the character limit, but it is only used in a text in the vstack. The code for the Stopwatch (Timer) file is: import SwiftUI struct Stopwatch: View { @Binding var progressTime: Int @Binding var isRunning: Bool /// Computed properties to get the progressTime in hh:mm:ss format var hours: Int { progressTime / 6000 } var minutes: Int { (progressTime % 6000) / 100 } var seconds: Int { progressTime % 100 } var timer: Timer { Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) {_ in progressTime += 1 reset() } } var body: some View { HStack(spacing: 2) { StopwatchUnitView(timeUnit: hours) Text(":") StopwatchUnitView(timeUnit: minutes) Text(".") StopwatchUnitView(timeUnit: seconds) }.onAppear(perform: { _ = timer }) } func reset(){ if isRunning == false{ self.timer.invalidate() print("invailidated") } } func toggleRun(){ if isRunning{ isRunning = false progressTime = 0 print(isRunning) timer.invalidate() }else{ isRunning = true } } func fetchTime() -> Int{ return progressTime } } struct StopwatchUnitView: View { var timeUnit: Int /// Time unit expressed as String. /// - Includes "0" as prefix if this is less than 10 var timeUnitStr: String { let timeUnitStr = String(timeUnit) return timeUnit < 10 ? "0" + timeUnitStr : timeUnitStr } var body: some View { HStack (spacing: 2) { Text(timeUnitStr.substring(index: 0)).frame(width: 10) Text(timeUnitStr.substring(index: 1)).frame(width: 10) } } } extension String { func substring(index: Int) -> String { let arrayString = Array(self) return String(arrayString[index]) } } struct stopwatch_Previews: PreviewProvider { static var previews: some View { Stopwatch(progressTime:.constant(0), isRunning: .constant(true) /*firstRun: .constant(true)*/) } } Could somebody help me reset the timer each time and fix the issue?
3
0
1.3k
Jun ’23
Date attribute syncing across core data objects
I have been creating an app, and when I save the core data, I give two attributes, they are String and Date types. For some reason, the date attribute syncs across all the objects I save, while the time attribute is just fine. ContentView code is: import Foundation import SwiftUI import CoreData struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest(entity: Time.entity(), sortDescriptors: []) private var times: FetchedResults&lt;Time&gt; ... var body: some View { VStack{ Text("Cube App") .font(.largeTitle) .fontWeight(.bold) .padding(.top, 4.0) Text(scrambles.randomElement()!) .font(.title) .fontWeight(.semibold) .multilineTextAlignment(.center) .padding([.top, .leading, .trailing]) if start{ Stopwatch(progressTime: $elapsedTime, isRunning: $timerRunning) .padding(.top) .fontWeight(.bold) .onAppear{ timerRunning = true toggleStartStop() } } Button(startstop){ toggleStart() if start == false{ saveTime = elapsedTime elapsedTime = 0 timerRunning = false stopTime() toggleStartStop() } } .fontWeight(.bold) .font(.system(size: 30)) .padding(.top, 30) Spacer() } } private func stopTime(){ timerRunning = false print(saveTime) addTime() } private func addTime(){ withAnimation{ timeMinutes = saveTime / 6000 timeSeconds = (saveTime % 6000) / 100 timeMilliseconds = saveTime % 100 let time = Time(context: viewContext) let date = Date() if timeMinutes == 0{ if timeMilliseconds &lt; 10{ time.time = "\(timeSeconds).0\(timeMilliseconds)" }else{ time.time = "\(timeSeconds).\(timeMilliseconds)" } }else if timeMilliseconds &lt; 10{ if timeSeconds &lt; 10{ time.time = "\(timeMinutes):0\(timeSeconds).0\(timeMilliseconds)" }else{ time.time = "\(timeMinutes):\(timeSeconds).0\(timeMilliseconds)" } }else{ if timeSeconds &lt; 10{ time.time = "\(timeMinutes):0\(timeSeconds).\(timeMilliseconds)" }else{ time.time = "\(timeMinutes):\(timeSeconds).\(timeMilliseconds)" } } time.date = date saveContext() } } private func saveContext(){ do { try viewContext.save() } catch { let error = error as NSError print(error) fatalError(error as! String) } } private func toggleStart(){ if start{ start = false }else{ start = true } } ... } struct ContentView_Previews: PreviewProvider { static var previews: some View { let persistenceController = PersistenceController.shared ContentView().environment(\.managedObjectContext, persistenceController.container.viewContext) } } I also have another view to display all of the saved objects in a list, the code is: import SwiftUI import CoreData struct timeListView: View { @Environment(\.managedObjectContext) private var viewContext @FetchRequest(entity: Time.entity(), sortDescriptors: []) private var times: FetchedResults&lt;Time&gt; @State var formattedTime: String = "" // format date and display var body: some View { VStack{ Text("Times") .font(.largeTitle) .fontWeight(.bold) .multilineTextAlignment(.center) .padding(.top, 4.0) List{ ForEach(times) {time in HStack{ Text(time.time ?? "Not found") .onAppear{ getDate(time: time) } Spacer() Text(formattedTime) } } .onDelete(perform: deleteTime) } } } private func getDate(time: Time){ let date = time.date! let calendar = Calendar.current let hour = calendar.component(.hour, from: date) let minute = calendar.component(.minute, from: date) let second = calendar.component(.second, from: date) let timeToFormatComponents = DateComponents(calendar: calendar, year: calendar.component(.year, from: date), month: calendar.component(.month, from: date), day: calendar.component(.day, from: date), hour: hour, minute: minute, second: second ) let timeToFormat = timeToFormatComponents.date! let formatter = DateFormatter() formatter.dateStyle = .short formatter.timeStyle = .medium formattedTime = formatter.string(from: timeToFormat) //UNSYNC THE DATES } private func deleteTime(offsets: IndexSet){ withAnimation{ offsets.map { times[$0] }.forEach(viewContext.delete) saveContext() } } private func saveContext(){ do { try viewContext.save() } catch { let error = error as NSError print(error) fatalError(error as! String) } } } struct timeListView_Previews: PreviewProvider { static var previews: some View { let persistenceController = PersistenceController.shared timeListView().environment(\.managedObjectContext, persistenceController.container.viewContext) } } Could somebody please tell me how to unsync the dates and make sure they are separate? I will attach images of what is happening below: I save the first one: And then I save the second one:
3
0
947
Jun ’23
Problems with core data in SwiftUI
I have been working on a 3x3 Rubik's cube app for iOS, and I have a timer in it. Whenever I try to add a time and save the context in a preview, it gives an error. func addTime(){ print("Started") formatTime() print("Formatted") withAnimation(){ print(formattedTime) let time = Time(context: viewContext) time.time = formattedTime print(time.time!) do{ print("dostart") try viewContext.save() print("saved") }catch{ let error = error as NSError print("An error occurred: \(error)") fatalError("An error occurred: \(error)") } } } This is the function that adds the time and saves the context.(The prints were for debugging purposes) When this function runs while testing in the preview, the do/catch returns "An error occurred: Foundation._GenericObjCError.nilError" When I try to run this in the simulator, it gives this error in Persistence.swift: If you need it, here is my entire ContentView.swift: import SwiftUI import CoreData var scrambles = ["R' B' L U' B2 D B' D' L R B L2 D' B L' U L2 B2 L B2 R' F L2 B' F' U2 B F' L2 F2", "D' B' L B' F L' B2 U' R2 D' U' L' D' R' F L U2 F' R2 D' B2 L' R' B' L R' U F L B2", "L R B' D' L D' U L2 R' B2 L' D2 U2 R' D' U' L D F' L2 D2 F D2 L' D' U' B' F2 U' B'", "U L2 R D' B2 D2 R2 D2 L2 R U2 R' U L2 D' F' D R B' F2 L' F' L B2 F' D' L R' F2 D"," D' U F L' R' U2 R' D B2 F U' L2 D2 B' L2 B2 R' F' D' U B' L' R' B' F L' B' L R2 D", "D2 U' F2 D' U' B2 F' U' R D2 U R2 D2 R2 U L B F2 D2 U2 B F2 L U2 F' U2 R D' L F'", "F D' U B F2 U' F' L2 B2 F2 U B2 F2 D' B' F' L' R2 B D U' B2 F' L' R B' U2 R2 D2 F'", "B F U2 B2 L U B F L2 R F' L2 F' U2 R B U' B2 U2 B' U2 L R D' U2 B' D L R' U"] var starts = ["Start", "Stop"] struct ContentView: View { @State var start = false @State var startstop = "Start" @State var watch = stopwatch() @State var elapsedTime: Int = 0 @State var timeToSave: Int = 0 @State var minutes: Int = 0 @State var seconds: Int = 0 @State var milliseconds: Int = 0 @State var formattedTime: String = "" @Environment(\.managedObjectContext) private var viewContext @FetchRequest(entity: Time.entity(), sortDescriptors: []) private var timecd: FetchedResults&lt;Time&gt; var body: some View { NavigationView{ VStack{ Text("CubeTimer") .font(.largeTitle) .fontWeight(.bold) .padding(2) Text(scrambles.randomElement()!) .multilineTextAlignment(.center) .padding(.top, 125.0) .padding(.leading, 15) .padding(.trailing, 15) .font(.title) .fontWeight(.bold) if start{ watch .padding(.top, 30) .fontWeight(.bold) .onAppear{ startstop = "Stop" watchToggle() } var timer: Timer { Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) {_ in elapsedTime += 1 //print("\(minutes).\(seconds)") print("called") print(elapsedTime) //figure out how to stop timer and save time to core data } } } Button(action: { start.toggle() if start == false{ timeToSave = elapsedTime print(timeToSave) print(elapsedTime) watchToggle() buttonToggle() addTime() } //print(start) }){ Text(startstop) }.padding(.top, 7) .font(.system(size: 30)) Spacer() //figure out how to stop timer and save time to core data } List{ ForEach(timecd){time in Text(time.time ?? "Not found") } } } } func buttonToggle(){ if start{ startstop = "Stop" }else{ startstop = "Start" } } func watchToggle(){ print("runs") watch.toggleRun() watch.testForIsRunning() //print(watch.isRunning) } func formatTime(){ print("Formatting") print(timeToSave) minutes = timeToSave / 6000 seconds = (timeToSave % 6000) / 100 milliseconds = timeToSave % 100 print(minutes) print(seconds) print(milliseconds) formattedTime = "\(minutes):\(seconds).\(milliseconds)" } func addTime(){ print("Started") formatTime() print("Formatted") withAnimation(){ print(formattedTime) let time = Time(context: viewContext) time.time = formattedTime print(time.time!) do{ print("dostart") try viewContext.save() print("saved") }catch{ let error = error as NSError print("An error occurred: \(error)") fatalError("An error occurred: \(error)") } } } func buttontext(){ if start{ startstop = "Stop" }else{ startstop = "Start" } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } Could somebody please help me resolve this issue?
0
0
776
Jun ’23