Post

Replies

Boosts

Views

Activity

Reply to Use @AppStorage with Arrays
unfortunately, nope. the work around is to do something like class SearchHistory { private static let maxHistoryItems = 50 @AppStorage("searchHistory") private var historyData: Data = Data() var recentSearches: [SearchHistoryItem] { get { guard let items = try? JSONDecoder().decode([SearchHistoryItem].self, from: historyData) else { return [] } return items } set { let limitedItems = Array(newValue.prefix(Self.maxHistoryItems)) if let data = try? JSONEncoder().encode(limitedItems) { historyData = data } } } }
1w
Reply to SwiftUI Gestures prevent scrolling with iOS 18
I also have this issue, no change in Xcode 16 RC and iOS 18 RC. this is very disappointing and will break a lot of apps. What's up apple? Or am I missing something how to fix this? I have a horizontal scroll view and each view has a drag gesture which on vertical drag would dismiss the view. This worked in iOS 17.5 and Xcode 15.4 but not on the latest as I mention above. My fix is to use .simultaneousGesture rather than just .gesture modifier block, it seems to work and the view is more dynamic as the horizontal scroll and individual view's drag gestures work together simultaneously rather than one or the other. Is this the intended behavior Apple wants? That's fine, but more explanation and documentation would really go a long way to help here.
Sep ’24
Reply to Managing Duplicate Objects in Core Data (or SwiftData) with CloudKit Sync When Devices were Offline during object creation
I would think you would want the duplicate behavior in this example? I can often have two people with the same first and last name but they are two different people, and the different age could be that distinguishing factor. I'm trying to think, when would you want this merged and not duplicated? Duplicating here seems to be the safe / correct behavior, no?
Aug ’24
Reply to Upvoting own post dilemma.
I think it's not about preference or ego, but how it affects the discoverability algorithm. Apple should follow SO or reddit as the OP suggests; probably SO approach, IMO, but either is better. Also unrelated but if I have your attention, I am noticing for some threads I am unable to boost or upvote any post, is this a bug or intended behavior?
Aug ’24
Reply to Do I need to add my own unique id?
This is a good question that I wish apple would discuss more. Yes as people suggest, it is a wrapper for NSManagedObjectID and it will change until its first save, as discussed here https://www.hackingwithswift.com/quick-start/swiftdata/how-to-save-a-swiftdata-object It's still not clear to me what is best practice, particularly when syncing with a cloud service or database such as postgres. Should I override the swift data id var with my postgres uuid? or have a separate var "cloudID" for it? Has anyone built real apps (not toy demos) with swift data and a server and found any gotchas or advice?
Aug ’24
Reply to Xcode cloud does not detect branches other than develop
I also have this issue. Now our project had Xcode cloud setup with a different repo in the past, I have added our new repo (its a complete rewrite) so there are 2 primary repos in Xcode cloud, and I created a workflow targeting the new repo. Everything seems to work except neither Xcode or AppStore Connect can see any branches, and so I can't trigger a build. Is deleting all Xcode Cloud data and starting over the only solution?
Jun ’24