Я использую автоматизацию ярлыков для запуска моего приложения, когда открывается конкретное приложение (например, Instagram). После выполнения задачи в моем приложении я возвращаюсь в исходное приложение, но намерение повторно переоценивает в процессе возврата, создав бесконечный цикл.@MainActor
func perform() async throws -> some IntentResult {
// Need loop prevention logic here
return .result()
}
< /code>
, указав Static let openappwhenrun: bool = false, целевое приложение больше не запущено по намерению./// Each intent needs to include metadata, such as a localized title. The title of the intent displays throughout the system.
static let title: LocalizedStringResource = "Open Favorite Trails"
/// An intent can optionally provide a localized description that the Shortcuts app displays.
static let description = IntentDescription("Opens the app and goes to your favorite trails.")
/// Tell the system to bring the app to the foreground when the intent runs.
static let openAppWhenRun: Bool = true
/**
When the system runs the intent, it calls `perform()`.
Intents run on an arbitrary queue. Intents that manipulate UI need to annotate `perform()` with `@MainActor`
so that the UI operations run on the main actor.
*/
@MainActor
func perform() async throws -> some IntentResult {
navigationModel.selectedCollection = trailManager.favoritesCollection
/// Return an empty result, indicating that the intent is complete.
return .result()
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... automation
Как я могу избежать бесконечного цикла, вызванной автоматизацией ярлыки? ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Проблема с автоматизацией получения данных с веб-страницы (Python, Selenium) [закрыто]
Anonymous » » в форуме Python - 0 Ответы
- 6 Просмотры
-
Последнее сообщение Anonymous
-