Я использую автоматизацию ярлыков для запуска моего приложения, когда открывается конкретное приложение (например, 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
Программируем под IOS
1745852838
Anonymous
Я использую автоматизацию ярлыков для запуска моего приложения, когда открывается конкретное приложение (например, 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()
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79596608/how-can-i-avoid-an-infinite-loop-caused-by-a-shortcut-automation[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия