Search results for

calendar

1,863 results found

Post

Replies

Boosts

Views

Activity

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<Time> ... 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() togg
3
0
1.2k
Jun ’23
Reply to DateFormatter, fixed-format dates and iOS Simulator
I've tried to write a test to further isolate the issue to the formatter. func testGivenFixedFormatDateAssertComponents() throws { var calendar: Calendar = Calendar(identifier: .gregorian) calendar.timeZone = TimeZone(identifier: UTC)! let dateComponents = DateComponents(calendar: calendar, year: 2023, month: 3, day: 8, hour: 12, minute: 10) let given = 08/03/2023 12:10 let actual = try DateFormatter.date(string: given) let expected = try XCTUnwrap(dateComponents.date) XCTAssertEqual(actual, expected) ///XCTAssertEqual failed: (2023-03-08 17:10:00 +0000) is not equal to (2023-03-08 12:10:00 +0000) }
Topic: App & System Services SubTopic: General Tags:
Jun ’23
Reply to DateFormatter, fixed-format dates and iOS Simulator
I now had a chance to make the suggested code changes and test this again. Unfortunately, this hasn't solved the issue. Here is the new code: extension Date { /// Creates a `user-visible` date string with the given `template` for the given `locale` using the given `dateFormatter`. Effectively, this gives you 3 benefits: /// /// * You don't need to compute/guess the appropriate date format for every locale /// * You are guaranteed to always format a date that is localised to the user's locale /// * You respect user's preference on how to format a date /// /// The default arguments allow you to to create a `user-visible` date string that is localised to the user's current locale. /// /// Alternatively, use this method to create the correct date string for the given locale. e.g. /// /// Given a `template` of `yMMMMd` to create a `user-visible` date string that includes the year, full name of the month and day of the month for a `en_GB` locale, the string returned for a date representing April 1st in 1974 will be
Topic: App & System Services SubTopic: General Tags:
Jun ’23
Coding help requested
I am relatively new to coding and put together this countdown timer based on code available in various public forums. This countdown timer for my iPhone puts a timer on my screen, allows me to select the time counted down in minutes and seconds, then to start the timer and, if so desired, reset it.While such timers are readily available, I wanted to try and build one myself and learn swift in the process. The program builds and runs fine. However the latter section is intended to play a chime when the countdown timer reaches the 1/2 way point and then when it finishes. This is not working and I'm at a loss to get it to do so. I would appreciate it if someone would modify my code to make this work. Also, I don't know how to compile the program so that I can move it off my MacBook and onto my iPad and would appreciate guidance on that. The code follows: Thank you // // Content-ViewModel.swift // Countdown Timer // // // import Foundation import AVFoundation extension ContentView { //contains the initial user in
3
0
971
Jun ’23
Reply to Get events from a calendar url
Try doing a GET HTTP request on the URL. It should send back an ICS file containing the events for the calendar. You could then parse this to find the events in the calendar. There's no EventKit api to parse an ICS file or to resolve an iCal URL to EventKit objects.
Topic: App & System Services SubTopic: General Tags:
Jun ’23
Handling permissions in a Swift Library
I am developing a dynamic library in Swift for MacOS that will be used by another app as a plugin. The app is not written in Swift and I cannot access its source nor modify it. The problem is that my library should provide access to the Calendar using EKEventStore, but then I can't seem able to requestAccess to the library since the application which will be using my library as a plugin doesn't have the necessary NSCalendarsUsageDescription entry in its Info.plist (it's not even written in Swift) and it seems I cannot just specify such an entry in the Info.plist of my library. What is the recommended way to give calendar access permission to a library? Or otherwise, is there a way for a library to modify the access requirements of an app?
1
0
837
Jun ’23
Reply to Handling permissions in a Swift Library
Any app using your library must provide the usage description string. There's no way around this. That's because malicious frameworks could otherwise provide a usage description and get access to calendar information without the app using the framework ever knowing. Note that on more recent versions of the OS the usage description string names have changed: TN3152: Migrating to the latest Calendar access levels | Apple Developer Documentation
Topic: App & System Services SubTopic: General Tags:
Jun ’23
DateIntervalFormatter with unexpected strings for some locales
I am currently facing a problem with DateIntevalFormatter. When using the formatter with dateStyle = .long and timeStyle = .none the string output for some locales is not in the expected formatting. While the output for locales like en_US, de_de or fr_fr is as expected, locales like zh_Hans, ja and ko is not consistent with the dateStyle = .long of a DateFormatter. Using the dateTemplate/setLocalizedDateFormatFromTemplate() with template MMMMddyyyy seems to provide a consistent output. Is that maybe a bug in DateIntervalFormatter? Here some exemplary output of the below Playground code: It seems that the forum is not accepting some of the Chinese, Korean or Japanese characters, therefore you can only find the actual output of below code as attachment. Code output import UIKit func printDate(starteDate: Date, endDate: Date, locale: Locale) { let interval = DateIntervalFormatter() interval.locale = locale interval.dateTemplate = MMMMddyyyy let formatter = DateFormatter() formatter.locale = locale formatter.setL
1
0
469
Jun ’23
Reply to i've noticed many times that applescript doesn't take this syntax
Make a note to post actual code, never pictures of code - you aren’t going to get many replies when people have to type in your script or debug formatting errors from the text recognition framework. The error is from trying to use Reminders to get the start date of a Calendar event. You need to target the appropriate application to use its terminology, for example: -- Set the names of your calendar and reminders set calendarName to appts set remindersName to appts -- Get the current date and time set currentDate to current date -- Get the events from the calendar tell application Calendar set calendarEvents to every event of calendar calendarName whose start date is greater than currentDate repeat with theEvent in calendarEvents set eventTitle to summary of theEvent set eventStartDate to start date of theEvent set eventNotes to description of theEvent if eventNotes is missing value then set eventNotes to (no notes) -- Create a new reminder with the event details te
May ’23
Reply to bind(_:to:withKeyPath:options:), Swift Error, Xcode 14.3 Mac mini(M1)
After scouring the internet to see whether I could discover a solution with better key words, such as [Binding and NSView], I noticed a quote posted more than five years ago, stating the following: Since KVC and KVO are built on the Objective-C runtime, and since Cocoa Bindings is built on top of KVC and KVO, any properties you want to use Cocoa Bindings with need to be exposed to Objective-C. At the bare minimum, that means adding @objc to the declaration. So, my original [Date] property was set to: var currentTime: Date? I changed the [Date] property to: @objc var currentTime: Date? The application did not crash, but did not show the [Clock and the Calendar] updating. Further reading stated: However, if the property can be changed at runtime, there's an additional hurdle you need to jump through; you need to make sure that the KVO notifications will fire whenever the property's setter is called. Apple's implementation of KVO will use Objective-C magic to automatically add the needed notifications t
Topic: App & System Services SubTopic: General Tags:
May ’23
Reply to How Can I Programmatically Open Settings->Privacy & Security->Calendars
There is no supported way to open that specific Settings page [1]. However, if you go to your app’s own Settings page then the Calendar switch shows up there as well. Your app can open its own settings using UIApplicationOpenURLOptionsKey. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com [1] Or any other Settings page for that matter. See this post.
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’23