【问题标题】:Method not implemented in protocol (using wit.ai SDK)协议中未实现的方法(使用 wit.ai SDK)
【发布时间】:2015-01-12 20:46:23
【问题描述】:

我是第一次使用wit.ai iOS SDK,我按照官网https://wit.ai/docs/ios/3.1.1/quickstart的入门页面中的内容一步步进行操作。我收到了这个错误:

协议“WitDelegate”中的方法“witDidGraspIntent:entities:body:error:”未实现。

我仍然可以运行应用程序,并且消息显示在我的收件箱中(在控制台中),但没有发回响应并且应用程序崩溃。我收到了这个错误:

从回调中排队缓冲区时出错

这是我的代码

ViewController.m

#import "ViewController.h"
@interface ViewController ()

@end

@implementation ViewController {
    UILabel *labelView;
}

- (void)witDidGraspIntent:(NSArray *)outcomes 
                messageId:(NSString *)messageId 
               customData:(id)customData 
                    error:(NSError*)e {
    //Implementation here...
    labelView.text = @"Hey what's up";
    [self.view addSubview:labelView];
}

ViewController.h

#import <UIKit/UIKit.h>
#import <Wit/Wit.h>

@interface ViewController : UIViewController <WitDelegate>


@end

谢谢。

【问题讨论】:

  • 你只实现了witDidGraspIntent:messageId:customData:error:。你需要(也?)实现witDidGraspIntent:entities:body:error:
  • 我应该添加一个新的 -void 吗?为什么这没有在网站的入门指南中列出?谢谢。
  • 您应该实现协议要求的所有方法。如果您还有其他问题,请直接联系入门指南的作者。
  • 我已经做到了。并在此处发布此问题,以防有人遇到相同问题并可以提供帮助。谢谢

标签: ios objective-c wit.ai


【解决方案1】:

伙计,您收到的崩溃消息准确地告诉您出了什么问题。

协议中的方法 'witDidGraspIntent:entities:body:error:' 'WitDelegate' 未实现。

您在协议的实现中缺少一个方法 (witDidGraspIntent:entities:body:error:)。您必须在协议中实现所有必需的方法。在这种情况下,缺少的方法是witDidGraspIntent:entities:body:error:

您问“我应该添加一个新的 -void 吗??”这样,如果您的意思是应该添加witDidGraspIntent:entities:body:error: 方法的实现,答案是YES

我之前没有使用过 wit.ai SDK。如果您不知道如何自行完成,您可能需要编辑您的问题并向使用该 SDK 的人寻求帮助以实现该方法。您可能还想在问题标题中添加“(使用 wit.ai SDK)”,以便熟悉该框架的人注意到您的问题。

【讨论】:

  • 现在可以使用了。这个方法实现没有问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-16
相关资源
最近更新 更多