" setObjectForKey:object不能为nil"同时请求Siri意图

时间:2016-12-16 16:48:33

标签: ios swift siri

2016-12-16 17:38:41.983033 FieldServiceIntentTimer[1380:101574] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: 8761C810-1DBE-43A0-B81B-571F1329699C)'
*** First throw call stack:
(0x1894091b8 0x187e4055c 0x1892e9a0c 0x189eafa8c 0x189eaf014 0x1882921fc 0x1882921bc 0x1882a03dc 0x1882959a4 0x1882a08d8 0x1882a234c 0x1882a20ac 0x18849b2a0 0x18849ad8c)
libc++abi.dylib: terminating with uncaught exception of type NSException

我打电话给Siri使用:"使用FieldService" 开始锻炼,我收到回复:"抱歉,您需要继续在应用程序。" 和控制台上面的错误。可能是什么原因?

我的Intent处理程序类:

import Intents

class StartWorkoutIntentHandler: INExtension, INStartWorkoutIntentHandling {

    //MARK: - INStartWorkoutIntentHandling

    func confirm(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void) {
        completion(INStartWorkoutIntentResponse(code: .continueInApp, userActivity: nil))
    }

    public func handle(startWorkout intent: INStartWorkoutIntent, completion: @escaping (INStartWorkoutIntentResponse) -> Void) {

        let userActivity = NSUserActivity(activityType: NSStringFromClass(INStartWorkoutIntent.self))
        let response = INStartWorkoutIntentResponse(code: .continueInApp, userActivity: userActivity)
        completion(response)
    }
}

0 个答案:

没有答案