以 url 作为属性的 RestKit 地图对象
我有以下 JSON,我喜欢将其映射到 Restkit 中。
{
"objects": [
{"name": "John Doe",
"contacts": [
"/url/to/contact/1/",
]
}
}
RestKit 是否可以结合 Core Data 直接映射此信息,在这种情况下,如果 id 为 1 的联系人存在,则不会按照 url 检索联系人。 完成这项工作的最佳方法是什么?
I have the following JSON which I like to map in restkit.
{
"objects": [
{"name": "John Doe",
"contacts": [
"/url/to/contact/1/",
]
}
}
Is it possible in RestKit to map this directly, combined with Core Data, in which case if the contact with id 1 exists do not follow the url to retrieve the contact.
What is the best way to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,你可以,但你应该脱水你的联系人,以便你得到 id 而不是 url,restkit 映射关系与 id 而不是 url。然后按照这篇文章操作:没有 KVC 的 RestKit 对象映射关系
Yes you can, but you should dehydrate your contacts so that you get the id instead of a url, restkit map relationships with id not url. Then follow this post : RestKit Object Mapping Relationships without KVC