Post

Replies

Boosts

Views

Activity

Reply to @Observable and didSet?
So didSet is allowed but you're not able to do much with it as you cannot make any reference to self or any of it's members: Cannot find 'self' in scope; did you mean to use it in a type or extension context? Instance member 'scalingMode' cannot be used on type 'MySettings'; did you mean to use a value of this type instead?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’23
Reply to SwiftUI window aspect ratio
Another solution that seems to work is to use NSViewControllerRepresentable to create a NSViewController based view. When viewDidAppear is called, you can set the NSWindowDelegate to self to receive window events and set the aspect ratio.
Topic: UI Frameworks SubTopic: AppKit Tags:
Dec ’22
Reply to ShareLink + FileRepresentation: Can't Save to Files
I would tend to think that the issue is with the try! statement. write(to:) can throw, which is probably the case here. Force unwrapping probably causes the crash. Here's an example of an implementation that works (at least on my end): static var transferRepresentation: some TransferRepresentation {         FileRepresentation(contentType: .myArchive) { archive in             let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent(archive.fileName)             let res = try JSONEncoder().encode(archive)             try res.write(to: url, options: .atomicWrite)             return SentTransferredFile(url)         } importing: { received in             let data = try Data(contentsOf: received.file)             return try JSONDecoder().decode(MyArchive.self, from: data)         }     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to Set filename to use for "Save to Files" with ShareLink?
Ok so I made some progress. Turns out I was using com.public.data instead of public.data in Exported Type Identifier > Conform To. So now saving to files will use the proper file extension (.cararchive) I've set in Exported Type Identifier > Extensions. However, the filename defaults to what I've set in Exported Type Identifier > Description. I'd like to set a default name myself as the one used by iOS makes no sense.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’22
Reply to What is causing this BadDeviceToken response from APNs?
Anyone?
Replies
Boosts
Views
Activity
Jun ’23
Reply to @Observable and didSet?
Thanks Chad! Please post your feedback reference so I can file a bug on my end as well!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to @Observable and didSet?
How is ScalingMode defined ? Just an enum ? Yes: enum ScalingMode: Int { case scaled case actualSize }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to @Observable and didSet?
So didSet is allowed but you're not able to do much with it as you cannot make any reference to self or any of it's members: Cannot find 'self' in scope; did you mean to use it in a type or extension context? Instance member 'scalingMode' cannot be used on type 'MySettings'; did you mean to use a value of this type instead?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’23
Reply to TableColumn with text and image
Someone suggested this solution: Text(Image(systemName: "desktopcomputer")) + Text(verbatim: " ") + Text(computer.name) Not great but at least it works. I think this should be addressed by the SwiftUI team. Apple folks: FB12004569
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Can't set focus with tab key when text fields are in a form (iPadOS)
Apple folks: FB11983812
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to What is causing this BadDeviceToken response from APNs?
I have the same problem for one of my projects. aps-environment is set to development but it receives a production token. Anything else could be triggering this?
Replies
Boosts
Views
Activity
Jan ’23
Reply to Buttons with label won't show in keyboard shortcuts list on iPad
If you set labelStyle to titleOnly, then the shortcut will show in the list: Button { // Do something } label: { Label("New", systemImage: "plus") .labelStyle(.titleOnly) } Still, that shouldn't make a difference.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Buttons with label won't show in keyboard shortcuts list on iPad
Apple folks: FB11889812
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to macOS: Impossible to set focus on a textfield embedded in an alert
Apple folks: FB11887007
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to iOS: List selection is reset to nil when app is sent to background
Apple folks: FB11876396
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to SwiftUI window aspect ratio
Another solution that seems to work is to use NSViewControllerRepresentable to create a NSViewController based view. When viewDidAppear is called, you can set the NSWindowDelegate to self to receive window events and set the aspect ratio.
Topic: UI Frameworks SubTopic: AppKit Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Files.app "On My ..." folder URL?
Turns out all you need to do is set LSSupportsOpeningDocumentsInPlace to true in your app's info.plist
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Nov ’22
Reply to ShareLink + FileRepresentation: Can't Save to Files
I would tend to think that the issue is with the try! statement. write(to:) can throw, which is probably the case here. Force unwrapping probably causes the crash. Here's an example of an implementation that works (at least on my end): static var transferRepresentation: some TransferRepresentation {         FileRepresentation(contentType: .myArchive) { archive in             let url = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true).appendingPathComponent(archive.fileName)             let res = try JSONEncoder().encode(archive)             try res.write(to: url, options: .atomicWrite)             return SentTransferredFile(url)         } importing: { received in             let data = try Data(contentsOf: received.file)             return try JSONDecoder().decode(MyArchive.self, from: data)         }     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22
Reply to Set filename to use for "Save to Files" with ShareLink?
Ok so I made some progress. Turns out I was using com.public.data instead of public.data in Exported Type Identifier > Conform To. So now saving to files will use the proper file extension (.cararchive) I've set in Exported Type Identifier > Extensions. However, the filename defaults to what I've set in Exported Type Identifier > Description. I'd like to set a default name myself as the one used by iOS makes no sense.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’22