Post

Replies

Boosts

Views

Activity

Reply to Best practice for removePendingNotificationRequests with CoreData
Thank you, I'm now having trouble because I want to use the .onDelete(perform: ) to call two functions, the actual delete function then the delete notification function. I don't know how to call two functions, though: .onDelete(perform: deleteItems) Here are my two functions:     private func deleteItems(offsets: IndexSet) {         withAnimation {             offsets.map { items[$0] }.forEach(viewContext.delete)             do {                 try viewContext.save()             } catch {                 print("There was an error deleting items")             }         }     }     private func removeSingleNotification(meetingID: String) {         notificationManager.removePendingNotificationRequests(meetingID: meetingID)     } So I want to call both of these with the onDelete but I don't know how to include both functions because when I do, I get a compiler error that it can't type check in a reasonable amount of time. Thank you.
Feb ’21
Reply to Can't Figure Out How to Use Function
Text statement is correct - doesn't compile even with static string. Code is below: import SwiftUI import Foundation struct OneTimeRow: View {     @Environment(\.openURL) var openURL     var oneTimeName: String     var oneTimeLink: String?     var oneTimeDate: Date     var oneTimeNotes: String?     var body: some View {         HStack {             VStack(alignment: .leading){                 Text("\(oneTimeName)")                     .font(.title3)                     .fontWeight(.semibold)                     .padding(.top, 5.0)                     .padding(.bottom, 0)                 if isDateInToday(oneTimeDate) {                     Text("Today at \(oneTimeDate, formatter: itemFormatter)")                 } else if isDateinYesterday(oneTimeDate){                     Text("Yesterday at \(oneTimeDate, formatter: itemFormatter)")                 } else if isDateInTomorrow(oneTimeDate) {                     Text("Tomorrow at \(oneTimeDate, formatter: itemFormatter)")                 } else {                     Text("\(oneTimeDate, formatter: showDayFormatter) at \(oneTimeDate, formatter: itemFormatter)")                         .foregroundColor(Color.gray)                         .padding(.bottom, 3.0)                         .padding(.top, -3)                 }             }             Spacer()             Button {                 print("Sending to computer")                 guard let data = URL(string: "\(oneTimeLink ?? "undefined")") else { return }                 let av = UIActivityViewController(activityItems: [data], applicationActivities: nil)                 UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)             } label: {                 Image(systemName: "wave.3.right.circle.fill")                     .font(.title)                     .padding(.trailing, 1)             }             .buttonStyle(BorderlessButtonStyle())             Button {                 print("Joining on iPhone")                 openURL(URL(string: "\(oneTimeLink ?? "untitled")")!)             } label: {                 Text("JOIN")                     .fontWeight(.semibold)                     .foregroundColor(Color.white)                     .frame(width: 60.0, height: 30.0)                     .padding(.trailing, 1.0)                     .background(/*@START_MENU_TOKEN@*//*@PLACEHOLDER=View@*/Color.blue/*@END_MENU_TOKEN@*/)                     .cornerRadius(20.0)             }             .buttonStyle(BorderlessButtonStyle())             NavigationLink(destination: MeetingsDetailView(detailMeetingName: "\(oneTimeName)", detailMeetingLink: "\(oneTimeLink ?? "Undefined")",  detailMeetingTime: oneTimeDate, detailMeetingNotes: "\(oneTimeNotes ?? "No notes")")) {             }             .frame(width: 10)         }     } } private let itemFormatter: DateFormatter = {     let formatter = DateFormatter()     formatter.timeStyle = .short     return formatter }() private let showDayFormatter: DateFormatter = {     let formatter = DateFormatter()     formatter.dateStyle = .short     return formatter }()
Feb ’21
Reply to Can't Figure Out How to Use Function
Ok, I've imported Foundation, but I'm still getting a compiler error: "Cannot find 'isDateInToday' in scope". I've cleaned the build folder and attempted to build. My code: if isDateInToday(oneTimeDate) {                     Text("Today at \(oneTimeDate, formatter: itemFormatter)") oneTimeDate is a variable of type date.
Feb ’21
Reply to Using CoreData entity in SwiftUI view
Thank you, so now I have something like this var meeting: Meeting But the PreviewProvider now says it is missing an argument for the parameter 'meetings'. How do I initialize some dummy data for the preview if the data is in CoreData? I have 'meetingName' of type string, 'meetingLink' of type URI, and 'meetingTime' of type Date. Thank you!
Feb ’21