【问题标题】:Compilation errors using RestKit使用 RestKit 的编译错误
【发布时间】:2011-11-29 07:57:19
【问题描述】:

我正在学习 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 未声明

【问题讨论】:

  • 你是如何安装 RestKit 的?您是否遵循本指南? github.com/RestKit/RestKit/wiki/Installing-RestKit-in-Xcode-4.x
  • 你有没有 #imported 需要的来自 RestKit 的头文件?
  • 确保你已经导入了
  • @mja:是的,我关注了 github.com/RestKit/RestKit/wiki/Installing-RestKit-in-Xcode-4.x。
  • @mattigalloway:我导入了“#import ”,并且我已经实现了使用 RKReachabilityObserver 获取网络状态的代码,它工作正常。

标签: objective-c compiler-errors restkit


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2011-07-13
    • 1970-01-01
    • 2012-08-26
    • 2016-08-23
    • 1970-01-01
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多