假设我已经FooIntent在.intentdefinition文件中定义了一个名为 的自定义意图。
它有一个bar类型Decimal为的单个参数,其中:
-User can supply value in Siri and Shortcuts app是活动的。
-Default Value是0。
其自动生成的类定义现在如下所示:
public class FooIntent: INIntent {
@NSManaged public var bar: NSNumber?
}
Run Code Online (Sandbox Code Playgroud)
如果我构造 a FooIntent,设置bar为nil,并将其传递给 a INUIAddVoiceShortcutViewController:
let intent = FooIntent()
intent.bar = nil
intent.suggestedInvocationPhrase = "Do foo"
let shortcut = INShortcut(intent: intent)
let viewController = INUIAddVoiceShortcutViewController(shortcut: shortcut!)
viewController.delegate = self
window?.rootViewController?.present(viewController, animated: true, completion: nil) …Run Code Online (Sandbox Code Playgroud)