Custom Intent class and handling protocol in Objective C

Hi,


I try to use Intent App Extension and Custom Intent ( .intentdefinition file ) for an application developped in Objective-C

But i can't find the code about CustomIntent class and CursomIntentHandling protocol like in Swift


Should i do all manually ?


Thank you for help

Accepted Reply

OK, i found my mistake


In the .intentdefinition, select the custom intent

on the right, Show identity Inspector

the field "Custom class" contain the default name of the class : clic on the arrow to open the file

then you can #import "PrefixNameIntent.h" in your sources


If there is no arrow, it's because the file is not yet generated : you have to buil the project before.

so before coding with the new intent class,

create intent definition,

build the project,

and then, use the intent in code with #import

Replies

For example, with the sample code "Soup Chef"

https://developer.apple.com/documentation/sirikit/soup_chef_accelerating_app_interactions_with_shortcuts?language=objc


This code is automatically generated :

//
// OrderSoupIntent.swift
//
// This file was automatically generated and should not be edited.
//

import Foundation
import Intents

@available(iOS 12.0, watchOS 5.0, *)
@objc(OrderSoupIntent)
public class OrderSoupIntent: INIntent {

    @NSManaged public var soup: INObject?
    @NSManaged public var quantity: NSNumber?
    @NSManaged public var options: [INObject]?

}

/*!
 @abstract Protocol to declare support for handling a OrderSoupIntent. By implementing this protocol, a class can provide logic for resolving, confirming and handling the intent.
 @discussion The minimum requirement for an implementing class is that it should be able to handle the intent. The confirmation method is optional. The handling method is always called last, after confirming the intent.
 */
@available(iOS 12.0, watchOS 5.0, *)
@objc(OrderSoupIntentHandling)
public protocol OrderSoupIntentHandling: NSObjectProtocol {

How to use/find it if the project is in 100% Objective-C ?


Thank you

OK, i found my mistake


In the .intentdefinition, select the custom intent

on the right, Show identity Inspector

the field "Custom class" contain the default name of the class : clic on the arrow to open the file

then you can #import "PrefixNameIntent.h" in your sources


If there is no arrow, it's because the file is not yet generated : you have to buil the project before.

so before coding with the new intent class,

create intent definition,

build the project,

and then, use the intent in code with #import