使用 RestKit 的编译错误

发布于 2024-12-18 21:33:25 字数 1095 浏览 0 评论 0原文

我正在学习RestKit,我想发布多部分数据。

-(void)publishToServer:(AddTextObj *)aTextObj
{
    NSString *urlString =appDelegate.textUploadURL;
    RKRequestMultipartBody *body = [[RKRequestMultipartBody alloc] init];
    [body addField:"phoneNo" text:aTextObj.phoneNumber];
    [body addField:"name" text:aTextObj.userName];
[body addField:"messageText" text:aTextObj.messageText];
[body addField:"imei" text:aTextObj.imeiNumber];
[body addField:"latitude" text:aTextObj.latitude];
[body addField:"longitude" text:aTextObj.longitude];
[body addField:"messageTitle" text:aTextObj.messageTitle];
[body addField:"picture" image:aTextObj.picture fileName:@"picture.png"];   
[body finalizeBody];
RKRestRequest *rest = [[RKRequest alloc] 
                       initWithURL:[NSURL URLWithString:urlString] 
                       requestBody:body];
rest.delegate = self;
rest.requestMethod = RKRestRequestPost;
[rest go];
}

我收到以下错误:

  1. RKRequestMultipartBody 未声明
  2. RKRestRequest 未声明
  3. RKRestRequestPost 未声明

I am learning RestKit, and I want to post multi-part data.

-(void)publishToServer:(AddTextObj *)aTextObj
{
    NSString *urlString =appDelegate.textUploadURL;
    RKRequestMultipartBody *body = [[RKRequestMultipartBody alloc] init];
    [body addField:"phoneNo" text:aTextObj.phoneNumber];
    [body addField:"name" text:aTextObj.userName];
[body addField:"messageText" text:aTextObj.messageText];
[body addField:"imei" text:aTextObj.imeiNumber];
[body addField:"latitude" text:aTextObj.latitude];
[body addField:"longitude" text:aTextObj.longitude];
[body addField:"messageTitle" text:aTextObj.messageTitle];
[body addField:"picture" image:aTextObj.picture fileName:@"picture.png"];   
[body finalizeBody];
RKRestRequest *rest = [[RKRequest alloc] 
                       initWithURL:[NSURL URLWithString:urlString] 
                       requestBody:body];
rest.delegate = self;
rest.requestMethod = RKRestRequestPost;
[rest go];
}

I'm getting these errors:

  1. RKRequestMultipartBody undeclared
  2. RKRestRequest undeclared
  3. RKRestRequestPost undeclared

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

万人眼中万个我 2024-12-25 21:33:25

我相信这个问题是由于遵循过时的教程引起的。导致编译问题的类不在最新的0.9 API中。请参阅 上的最新对象映射指南github

I believe the problem is caused by following an outdated tutorial. The classes that cause compilation problem are not in the latest 0.9 API. Please, refer to the most up-to-date Object Mapping guide on github.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文