Post

Replies

Boosts

Views

Activity

Transaction.latest(for:) returns nil in StoreKit 2
Using the Implementing a Store In Your App Using the StoreKit API sample code, I've successfully integrated my new APP with StoreKit 2. There is one problem though: when I call the method Transaction.latest(for:) to get the user’s latest transaction, it always returns nil. Here's the code snippet: guard let result = await Transaction.latest(for: myProductId) else { return false } Is this a bug with StoreKit 2, or am I doing something wrong? This happens on a physical device, running from Xcode. Thanks in advance.
4
0
2.2k
Jan ’22
SwiftUI view does not update when FetchRequest data changes from inside Action Extension
I'm sharing a Core Data store with my action extension, which adds data to it. My app has a SwiftUI view that presents this data, fetched with a FetchRequest: private struct VideosScrollView: View { @Environment(\.managedObjectContext) private var viewContext private var fetchRequest: FetchRequest<Video> init(sortOrder: String, tagIds: String, showWatched: Bool) { fetchRequest = Video.getFetchRequest(sortingBy: "addDate", with: sortOrder, showWatched: showWatched, tagIds: tagIds) } var body: some View { ScrollView { if fetchRequest.wrappedValue.isEmpty { ContentEmptyView() } else { ForEach(fetchRequest.wrappedValue) { item in VideoCellView(video: item) } } } } } After adding data from the action extension and going back to the app, the view is not updated. Only after CloudKit finished a sync is that the view notices something changed and updates itself. How can I force my SwiftUI view to update when data changes in the action extension?
1
0
1.1k
Dec ’21
How to reload widgets from the share sheet, via an Action Extension
My app has an action extension that allow users to collect and save links throughout the system. It also has a widget to show these links in the Home Screen. When adding links from the main app, I call WidgetCenter.shared.reloadAllTimelines() to reload all widgets, and everything works as expected. But when I add links from the action extension, widgets are not reloaded, even after calling WidgetCenter.shared.reloadAllTimelines(). Only when I go to the main app is that widgets do reload. How can I refresh my widgets for changes made via the Action Extension from the share sheet?
0
0
863
Dec ’21
Can't obtain the user's Apple Music token on macOS (Catalyst)
On a macOS app generated with Catalyst, the method SKCloudServiceController.requestUserToken(forDeveloperToken:completionHandler:) returns a SKErrorDomain. The error is: Error Domain=SKErrorDomain Code=0 "Ocorreu um erro desconhecido" UserInfo={NSLocalizedDescription=Ocorreu um erro desconhecido} Has something changed regarding this method on macOS or is this a bug?
9
0
2.3k
Dec ’21
SwiftUI: unexpected behavior with two List side by side and a NavigationView
I have a screen with two List side by side, inside a NavigationView. The layout is rendered correctly, and I can independently scroll both lists. The problem is that, when I scroll the first list, it goes behind the navigation bar without triggering the effect of applying a background color to it. Here's a gif showing what's going on: And this is the code I'm using for this view: struct ContentView: View { var body: some View { NavigationView { HStack(spacing: 0) { List { Section(header: Text("Header left")) { ForEach(0..<600) { integer in Text("\(integer)") } } } .listStyle(InsetGroupedListStyle()) .frame(minWidth: 0, maxWidth: .infinity) List { Section(header: Text("Header right")) { ForEach(0..<400) { integer in Text("\(integer)") } } } .listStyle(InsetGroupedListStyle()) .frame(minWidth: 0, maxWidth: .infinity) } .navigationTitle("Example") } .navigationViewStyle(StackNavigationViewStyle()) } } Would this be a SwiftUI bug? If not, how can I make the first list correctly interact with the navigation bar when scrolling?
0
0
911
Aug ’21
iPad keyboard navigation: where to initialize UIFocusHaloEffect
WWDC21 Session Focus on iPad keyboard navigation says that we can use UIFocusHaloEffect to change the appearance of focused items. On iPadOS, we can use this effect by assigning a UIFocusHaloEffect to the focusEffect property like so: self.focusEffect = UIFocusHaloEffect() What wasn't very clear is where should we put this code when working with UICollectionViewCell. I am doing it in the collectionView(_:canFocusItemAt:) method: func collectionView(_ collectionView: UICollectionView, canFocusItemAt indexPath: IndexPath) -> Bool { guard #available(iOS 15.0, *) else { return false } guard let cell = collectionView.cellForItem(at: indexPath) as? FeedCollectionViewCell else { return false } if cell.focusEffect == nil { cell.focusEffect = UIFocusHaloEffect(roundedRect: cell.artworkImageView.frame, cornerRadius: cell.cornerRadius, curve: .continuous) } return true } Is this the best way to implement it?
1
0
1.1k
Aug ’21
UICommand is disabled on UIMenu inside NSMenuToolbarItem.itemMenu on Catalyst
Before beta 4 this worked as expected. After updating to beta 4, all my UICommands inside UIMenu on NSMenuToolbarItem.itemMenu are now disabled, and I can't figure out how to enable them. Here's my itemForItemIdentifier method: func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { &#9;&#9;let item = NSMenuToolbarItem(itemIdentifier: itemIdentifier) &#9;&#9;item.itemMenu = UIMenu(title: "", options: .displayInline, children: [UICommand(title: "Test", action: #selector(onTestTap))]) &#9;&#9;item.image = UIImage(systemName: "ellipsis.circle") &#9;&#9;return item } Am I doing something wrong or is this a bug on macOS Big Sur beta 4?
5
0
2k
Apr ’21