跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[Swift] ios 17 widget 无法正确更新 core data

发表于

我正在开发的一个 iOS 17 Widget ,它可以为用户的 Thing 对象进行打卡。

当我同时创建多个 Widget 实例时,无论点击哪个 Widget 实例进行打卡,它们更新的都是第一个 Thing ,看起来多个 Widget 都重复指向了同一个 Thing 。

我后面经过排查,发现是我的 AppIntent 中,Parameter 并不起作用,用户无论选择哪个 thing,perform 中的 thing 都是 EntityQuery 中的 defaultResult 的返回值

struct ConfigurationAppIntent: WidgetConfigurationIntent {
    @Parameter(title:"Select thing")
    var thing: ThingData
    
    func perform() async throws -> some IntentResult {
            print("perform thing: \(thing)") // 这里会直接返回 defaultResult 的结果,而不是用户选择的 thing
	}
}

哪位大佬知道怎么解决吗?修了两天了,文档、视频、教程看了一遍,都没发现解决办法。。

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.