Search results for

calendar

1,863 results found

Post

Replies

Boosts

Views

Activity

Calendar nextDate/enumerateDates methods with backward direction does not work for September
I’m trying to get the previous date that matches the 9nth month in the Gregorian calendar (which is September) from Date.now (which is in December 2023 right now). The expected date is then in 2023. The first date returned is in 1995. Why? I filed the feedback FB13462533 var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone.autoupdatingCurrent let matchingDateComponents: DateComponents = DateComponents(month: 09) let date: Date? = calendar.nextDate( after: Date.now, matching: matchingDateComponents, matchingPolicy: .nextTime, direction: .backward ) print(date) // Optional(1995-08-31 23:00:00 +0000)
4
0
739
Dec ’23
In Swift, how can I get the "last Sunday of a month before the current date"?
I want to find the last Sunday of a month before the current date in Swift, but using the Calendar nextDate function doesn't work (always returns nil). var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = .gmt let lastSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: -1 ) let previousLastSundayDate: Date? = calendar.nextDate( after: Date.now, matching: lastSundayDateComponents, matchingPolicy: .nextTime, repeatedTimePolicy: .first, direction: .backward ) print(previousLastSundayDate ?? Not found) // Not found If I use a positive weekdayOrdinal, it's working normally and the same nextDate method provides the correct date. let firstSundayDateComponents: DateComponents = DateComponents( weekday: 1, weekdayOrdinal: 1 ) When I check if the date components can provide a valid date for the given calendar, it returns false... let lastSundayInNovember2023DateComponents: DateComponents = DateComponents( year: 2023, mo
2
0
1k
Dec ’23
Write Only permission not working with provided snippet
Hi, I am evaluating the write ony mode and on my Development iPhone (14 Max Pro / 17.2) I get an error when trying to add an event in write only access mode. I am using the provided snippet let store = EKEventStore() // Request write-only access guard try await store.requestWriteOnlyAccessToEvents() else { return } // Create an event let event = EKEvent(eventStore: store) event.calendar = store.defaultCalendarForNewEvents event.title = WWDC23 Keynote event.startDate = myEventStartDate event.endDate = myEventEndDate event.timeZone = TimeZone(identifier: America/Los_Angeles) event.location = 1 Apple Park Way, Cupertino, CA, United States event.notes = Kick off an exhilarating week of technology and community. // Save the event guard try eventStore.save(event, span: .thisEvent) else { return } On the .save step I receive the following Error (The calendar is read only) Failed to save event: Error Domain=EKErrorDomain Code=6 Der Kalender ist schreibgeschützt. UserInfo={NSLocalizedDescription=Der Kalender
1
0
891
Dec ’23
Calling an URSession task in background and display local notification
I would like to call a GetMessages API every 10 minutes while the app is not active or shutdown. if a message is returned, display the message as a local notification Will the background api run if the app is shut down? An example of this is when an email app shows a notification. Can they pull from their server while the app is not running or do they use the push notification service. I know that calendar events can be scheduled locally and for location changes, but I don't know if calling a api task with the app not running is possible.
1
0
743
Dec ’23
AppStoreConnect - Reports giving different numbers - which are right?
Hi, We are strugling to find out why some numbers in AppStoreConnect does not mach eachother. We have only 1 product - subscriptions in an app - nothing else. Yet - AppStoreConnect gives us: Payments and Financial report for oct: Sold - 1.545 units (which we translate as 1.545 subscriptions) Trends -> State -> Month ending 31st Oct says: 1.360 active subscriptions. I also went back to the very first months... Here I get: Payments and Financial reports: Jun-21: 106 Jul-21: 130 Aug-21: 135 Trends -> State -> Month ending: 30-jun-21: 5 31-jul-21: 125 31-aug-21: 156 So sometimes the number from one report is bigger than the other - and other times it is the other way around. I have read something about that it might be the dates, as the Apple calendar differs ... But that does not seem to explain things here, as I tried finding the exact date, where the Sold units from the payments report matched the state-report. Payments Jun-21: 106 State date July 24h: 106 Payments Jul-21: 130 State date A
0
0
626
Dec ’23
A random crash on DateFormatter
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libicucore.A.dylib 0x18c500918 icu::SimpleDateFormat::subFormat(icu::UnicodeString&, char16_t, int, UDisplayContext, int, char16_t, icu::FieldPositionHandler&, icu::Calendar&, UErrorCode&) const + 532 1 libicucore.A.dylib 0x18c500520 icu::SimpleDateFormat::format(icu::Calendar&, icu::UnicodeString&, icu::FieldPositionHandler&, UErrorCode&) const + 520 2 libicucore.A.dylib 0x18c5002f8 icu::SimpleDateFormat::format(icu::Calendar&, icu::UnicodeString&, icu::FieldPosition&) const + 84 3 libicucore.A.dylib 0x18c42c4ac icu::DateFormat::format(double, icu::UnicodeString&, icu::FieldPosition&) const + 176 4 libicucore.A.dylib 0x18c535c40 udat_format + 352 5 CoreFoundation 0x189349a14 __cficu_udat_format + 68 6 CoreFoundation 0x189349898 CFDateFormatterCreateStringWithAbsoluteTime + 192 7 Foundation 0x18a432bf0 -[NSDateFormatter stringForObjectValue:] + 316 8 ShiningUtiliesKit 0x105
1
0
827
Dec ’23
Reply to Background Task scheduling and Date. Should we use absolute or calendar date?
The properties you’re working with here are of type Date. A Date value is a floating point offset from the epoch (the start of 2001 GMT) and thus, in your terms, it’s always absolute [1]. How you create that Date value is up to you. If you want to generate it using Calendar, that’s fine. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] I don’t consider it to be absolute because it’s based on the wall clock and thus can change if the device’s time changes, but coming up with words to discuss all these concepts is hard.
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’23
Background Task scheduling and Date. Should we use absolute or calendar date?
Should we use absolute or calendar Date when scheduling background tasks? I would guess it doesn't matter how we construct Date but I wanted to double check since WWDC videos show both ways. I've experienced some instances where background tasks ran much later than expected, and while this is not surprising since iOS has many factors to consider when they allot background execution time, the times of execution seemed to line up with the hours change between Absolute and Calendar time. Or And I understand there is no guarantee that the system will run the background task exactly or even near the date requested. Thanks!
2
0
976
Nov ’23
EKEventStore().requestFullAccessToEvents() doesn't work with iOS 17
We don't need to add -- latest functions for iOS-17 as it introduces requestFullAccessToEvents. if #available(iOS 17.0, *) { eventStore.requestFullAccessToEvents(completion: { (granted: Bool, _: Error?) -> Void in completion(granted) }) } else { // Fallback on earlier versions eventStore.requestAccess(to: .event, completion: { (granted: Bool, _: Error?) -> Void in completion(granted) }) } Solution for iOS 17 Calendar request authorization is to add two keys in Info.plist file including previous key i.e. NSCalendarsUsageDescription We need this permission in order to set reminders for you NSCalendarsWriteOnlyAccessUsageDescription We need this permission in order to set reminders for you
0
0
580
Nov ’23
SwiftUI #Preview with Callback Closure
I have created a simple calendar framework of my own. The screenshot below shows what it looks like. The following lines show a concise version of my calendar framework. The deal is such that the app will return a date when I tap a date button with the callBack closure. import SwiftUI struct ContentView: View { @State private var navigateToAddDate = false @State private var days: [Day] = [] @State var callBack: ((Date) -> Void) private let cols = [ GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()), GridItem(.flexible()) ] var body: some View { NavigationStack { VStack { LazyVGrid(columns: cols) { ForEach(days, id: .self) { day in Button(action: { selectedDay = day navigateToAddDate.toggle() }, label: { Image(systemName: (day.num).circle.fill) .resizable() .aspectRatio(contentMode: .fit) .foregroundColor(day.show ? dateTextForecolor(day: day) : .clear) }) .disabled(day.isInvalid) } } } } } } struct Conte
3
0
1.7k
Nov ’23
Reply to macOS keeps showing "[App] would like to access data from other apps" warning even if accepting it each time
How is your app signed? A problem with the signature might prevent the OS from remembering that permission has been granted before. Thanks for the suggestion, but I don't think there's any problem with the signature. All other warnings (Calendar, Reminders, etc.) only get shown once, but this one gets shown each time. I think it only started appearing since macOS 14 Sonoma.
Topic: App & System Services SubTopic: General Tags:
Nov ’23
Multiple Days Schedules • Screen Time API
Hello, I wasn't able to figure out how to handle multiple days with DeviceActivitySchedule. For instance, let's say the user wants to block certain apps from 9:00 AM to 12:00 AM, every day except Saturday and Sunday, how my schedule should look like? I've tried different things... This schedule works for each day of the week, but that's not my goal: let schedule = DeviceActivitySchedule( intervalStart: DateComponents(hour: 9, minute: 00), intervalEnd: DateComponents(hour: 12, minute: 00), repeats: true) And if I specify the weekDay inside the DateComponents, like this: // Gregorian calendar // 2 -> Monday // 6 -> Friday let schedule = DeviceActivitySchedule( intervalStart: DateComponents(..., weekday: 2), intervalEnd: DateComponents(..., weekday: 6), repeats: true) the schedule will block the apps from Monday at 9:00 AM to Friday at 12:00 AM, which is also not my goal. The only workaround that came to my mind was to create a different schedule for each day of the week: enum WeekDays: String, Ca
5
0
2.1k
Nov ’23