使用 RestKit 的编译错误
我正在学习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];
}
我收到以下错误:
RKRequestMultipartBody
未声明RKRestRequest
未声明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:
RKRequestMultipartBody
undeclaredRKRestRequest
undeclaredRKRestRequestPost
undeclared
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这个问题是由于遵循过时的教程引起的。导致编译问题的类不在最新的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.