Post

Replies

Boosts

Views

Activity

Reply to How to control when a DatePicker "pops up"
Unfortunately, my situation is a bit more complicated. The result of tapping the "unscheduled" button is not to set the date to .now, but to allow the user to schedule the activity, presumably sometime in the future (but not Dec 31, 4000). Your solution requires two taps to set a correct date — first one to change "unscheduled" to .now, then the second to change .now to the date the user wants. While this will work (with your proviso about not being able to change the date back to "unscheduled", I'm still hoping for a cleaner interface.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’25
Reply to SwiftData Query and optional relationships
Ziqiao Chen, Well, I really thought I'd tried that, but decided to try again so that I could answer you properly. My results have two cases: (1) In Preview, where I explicitly populate Teams with one record, the Preview crashes. (2) In Simulator (simulating iPadOS 18.0), where I do not yet have the code installed to create a new record (and hence have no records for the query to find), the app does not crash. Obviously, the next step is to add "New Teams" logic so I can test this issue further. I'll report again once I've added that logic.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’25
Reply to TextFields inside a List lose focus after each character
To answer my own post — The problem is the ForEach function. Apparently you cannot use theid: \.self form with an editable row. I am guessing that editing the TextField affects the \.self ID and confuses the ForEach statement. The solution is to take the list of strings and use it to build an internal list of Identifiable structs that contain the strings. Then undo the process after completing the edits. This is messy but it works.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’24
Reply to iOS 17 apps still require 5.5" iPhones screenshots?
I'm having the same problem as everyone else, but I want to raise an additional concern. It is my understanding that the iPhone 8+ image will only be shown to users with a device that has that aspect ratio. So that means that only users of iPhone 8+ or earlier will see those screenshots. BUT, since the app required iOS 17+, they can't run the app. So providing the screenshots is essentially a case of BAIT AND SWITCH. By supplying the screenshots, the App Store is implying that the app is available when it is not. I don't want to speculate on Apple's motivation for doing this, but it makes ME look like the bad guy here. I don't think I should take the flack for this. What do you think?
Apr ’24
Reply to CloudKit backed SwiftData @Relationship
Unless the situation has changed recently, it is my understanding that cascade does not work in iCloud+CoreData. Since SwiftData seems to be a layer on top of CoreData, one would suspect that cascade shouldn't work for it either. This is, I agree, a real pain. In CoreData, there were enough hook functions in NSManagedObject that one could manually handle the cascade operation, but I've been unable to find any suitable hooks that could be used.
Dec ’23
Reply to SwiftUI - Open a file via a fileURL
Thank you, Quinn. I was sort of afraid of that, because the security-scoped URL includes device-specific information (a UUID-based directory name). And it gets even worse, because it appears at openURL only works with external (https ??) URLs, not file URLs. (I'm going to file that as a bug report next...) So it looks like I'm going to have to re-evaluate the requirements of my app (and offer a less-capable product as a result).
Topic: App & System Services SubTopic: General Tags:
Oct ’23
Reply to SwiftData #Predicate case insensitive String comparison
I'm sorry, but this isn't right. localizedStandardContains(_:) provides CONTAINS semantics, not EQUALS semantics. The original poster (and I) want a case-insensitive test for equality. Using localizedStandardCompare(_:) == .orderedSame is not supported by the current (Xcode 15.0 beta 7) version of SwiftData, and the alternative suggested by Xcode's error messages (localizedCompare(_:)) is case-sensitive. The only thing I can think of at this point (not tested, by the way) is $0. attribute.localizedStandardContains(str) && str.localizedStandardContains($0.attribute) which is ridiculous. FB13051739
Aug ’23
Reply to Core Data: Fatal Error sorting using a computed property
I put together a writeup of the technique I'm using. (Yes, it's kludgy and I would be delighted for someone to offer an improvement or a replacement.) If the writeup seems long (or insultingly detailed), please forgive me. I find writing this sort of thing helps me clarify my thinking. Be that as it may, since I can't attach either a Pages file or a PDF to this reply, I moved the writeup to my Dropbox. https://www.dropbox.com/s/nf2diu6haayn147/Pseudo-Transient%20Attributes.pdf?dl=0
Oct ’22
Reply to Core Data: Fatal Error sorting using a computed property
I finally worked out a solution to this problem, but it is a real hack. If you're interested in details, I can write it all up. However, in a nutshell, what I do is as follows: in any entity which contains an attribute that is used in the computation for the computed property, I use the validateForXXX methods to register changes. (The registration process is part of my CoreDataStack.) The entity which has the "computed" properties maintains real attributes with the computed values. The entity registers for notification for changes and performs the computations necessary to update the real (stored) values as appropriate. In this way, I am able to use a stored attribute (which can be the target of the find or sort operation) which is kept up to date. It's definitely kludgy (and requires more infrastructure that needs to be implemented correctly and consistently that I'd like), but I am finding it to be reliable. Again, I'll prepare a writeup if you're interested.
Apr ’22