I am seeing a weird behavior of the date formatter (Full code is below).
When run, this will give the following output:
57: 1 month, 3 weeks, 5 days
58: 1 month, 3 weeks, 6 days
59: 2 months
60: 2 months, 1 day
61: 2 months
62: 2 months, 1 day
63: 2 months, 2 days
So both 59 days and 61 days are 2 months, and both 60 and 62 days are 2 months and 1 day.
This of course is especially weird because this means, 2 months also comes after 2 months and a day.
Can someone explain to me what is going on here?
import Foundation
let formatter = DateComponentsFormatter()
formatter.unitsStyle = .full
let calendar = Calendar(identifier: .gregorian)
let today = calendar.date(from: DateComponents(year: 2025, month: 7, day: 26))!
for day in 57...63 {
let startDate = calendar.date(byAdding: .day, value: -day, to: today)!
let components = calendar.dateComponents([.day, .weekOfMonth, .month,. year], from: startDate, to: today)
let result = formatter.string(from: components)!
print ("\(String(format: "%3d", day)): \(result)")
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I would like to declare an @EnvironmentObject as a protocol, namely as
protocol AccessTokenProvider: Authenticator {
func accessToken() - AccessTokenPublisher
}
where Authenticator is
public class Authenticator: NSObject, ObservableObject
However, when I add this to the environment as
var authenticator: AccessTokenProvider = MyAuthenticator()
[…]
ContentView().environmentObject(authenticator)
the compiler throws an error at:
struct ContentView: View {
// error: property type 'AccessTokenProvider' does not match that of the 'wrappedValue' property of its wrapper type 'EnvironmentObject'
@EnvironmentObject var authenticator: AccessTokenProvider
^
Is this even a good idea? If so, what am I doing wrong?
^
As I currently live in ReactNative Hell, I like to flesh out all my native iOS demos and samples to the max. Including things like accessibility. Recently, I wrote a very simple demo containing a map, and I stumbled upon some issues I was unable to resolve. I think they present very general usecases, and so I would be happy if anyone of you had any idea.
The condensed source code for the issues can be found on GitHub
Issue 1: The Phantom Overlay
To reproduce Run the app on a device, and be sure that VoiceOver is on. Swipe right to get to the Annotations.
Expected Result The title of the annotation is read.
Actual Result The title of the annotation is read twice.
What I know For every annotation on the map view, there is also an overlay, an MKCircle, generated by an MKCircleRenderer. When this overlay is not present, the title is — correctly — only read once.
What I have tried In ViewController.swift, lines 54 and 92, I have set both the overlay's and the renderer's isAccessibilityElement property to false. This does not fix the issue (probably because neither of them are the actual views).
The overlay should never be an accessible element. Any information should be encoded in the annotation (e.g. "There is a 10m region around this marker")
Issue 2: The Unknown Trait
While it is correct that the title of the annotation should be read, there is no indication that the annotation can be clicked or interacted with. I have set annotationView.accessibilityTraits = [.button], but this does not change anything. My expectation would be "Cologne Cathedral, Button" or a similar hint that the item is clickable.
Issue 3: The Unreachable Callout
With VoiceOver active, click on an annotation. I have taken some hints from Stackoverflow, and tried to disable the accessibility on the annotation, and enable it on the callout. This leads to the callout being reachable somehow, but it is absolutely not obvious if you can not see the screen.
How can I indicate to the VoiceOver user that now a callout is being shown?
A Working Extra: The Annotation Rotor
The app also contains a custom rotor, to go through the annotations one by one, without also reading the default Points-Of-Interest on the map. Interestingly (or maybe rather as expected), the title of the annotation is correctly only read once.
I whould be extremely happy to get some feedback on these issues, it sounds like most of them could be rather common.
Thanks!
Alex
Context: Authorized Network requests.
I have a process (a publisher, to be precise), which will give me a fresh access token for a request.
To do that, I may need user interaction, i.e. show a View, Alert, or something like that.
How can I do that in SwiftUI? Can I just (modally) display something, without explicitly being in a View body? Should I have to pass in a "superview" to do this, or do you have other ideas?
Thanks
Alex
After I realized that the download site now tries to open a popup, I was able to get the download for Xcode 15 Beta and the selected Simulator SDKs
Now, no matter where I unpack and start Xcode 15, it wants to re-download these files.
What is the way this is supposed to work? Where should I put my downloads and uncompressed files?