问题标签 [restkit-0.20]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
objective-c - RestKit .2 将图像发布到 Web 服务 - 空实体错误
我正在使用 RestKit 将图像发布到 Web 服务,并且它们发布得很好,服务器发回了 200。发生的事情是我收到以下错误:
***
由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[valueForUndefinedKey:]:实体(null)与键“resource_updated_at”的键值编码不兼容。
这是我用来发布图像的方法。我希望有一些明显的东西我错过了。我发现一个类似的帖子提到核心数据堆栈可能没有正确设置,但我不确定如何。我正在使用 RestKit 发布其他标准表单数据,它返回和映射就好了。
另外,这是init
我设置 的方法RKManagedObjectStore
,以防万一。
这是Image class
代表Core Data Entity
我会提出这可能不是最好的代码的免责声明。但如果你看到错误,请告诉我:]。
mapping - 如何使用此 JSON 实现动态映射 (RKDynamicMapping)?
我的后端返回这种 JSON 文件:
{“响应”:{“消息”:“测试”},“响应代码”:205 }
根据 responseCode 值,响应内部的内容是不同的。我知道我必须使用 RKDynamicMapping 之类的东西,但不确定如何使用。我看到的问题是,在示例代码和手册中,区分映射的属性在内部,但在这种情况下在外部。我试过这个但不起作用:
我猜是因为我要更改的映射不包含区分它们的属性(例如输入来自 rest kit 网站的女孩/男孩示例代码)
有人有什么建议吗?提前致谢。
restkit - NTML 身份验证和 Restkit (0.2.0) - 未为对象请求设置 defaultCredentials
这是适用于 iOS 的 Restkit v0.2.0。
我正在尝试通过设置 HTTP 客户端的默认凭据来使用 Windows 身份验证,以便在请求的身份验证受到质疑时它可以工作。
我这样做:
然后我尝试获取我的对象:
但它不起作用,我总是得到“它失败”并且页面显示“无效凭据”。
所以我开始环顾四周,发现我需要响应身份验证挑战,但这已经完成了。如果我遍历执行此操作的方法,我的凭据为零(0x00000000)。我走过的方法是这样的:
所以我做了一些探索,发现 defaultCredentials 是在这个方法中设置的:
但不是这个,这是一个被称为:
所以我的凭据永远不会被设置,我不明白为什么。尤其是为什么它不使用 HTTPRequest 和 HTTPClient 连接以及所有相应的爵士乐?
我可能调用了错误的方法吗?有没有办法通过客户端强制它?
还是有另一种更好的方法来为所有请求设置凭据?
任何帮助表示赞赏!谢谢!
iphone - addResponseDescriptors 多个
我想在这里问一些事情。我已经映射了对象并将其添加到 RKResponseDescriptor 并且它可以工作,但是这里有一个问题。当来自 JSON 的数据不同时,它不会映射到已经创建的对象我只是意识到它没有很好地映射。
编辑编号 1:
对于这个,可以映射用户的 JSON 数据,但不能映射另一个。我的意思是我们可以像这样映射对象吗?因为我改变了 responseDescriptors 的顺序,它只是映射了底部的对象。
对不起我以前的英语不好
iphone - 如何在 RestKit 0.20 中映射 JSON 数组
这是我第二次在这里问。我有一个类似这样的 JSON 响应
现在,我想从帖子中映射类别
在类别.h
映射代码是
最后一件事。在日志中
我是,在另一篇文章中搜索我必须使用 usingBlock 或其他东西。但是 usingBlock 没有显示在自动完成代码中。
iphone - Restkit will not insert object attributes to path pattern for request URL path
I'm trying to run a find by ID request on a REST API. I'm using RestKit 0.20. I have a Location object. It has an id attribute. I want to make a GET request to '/locations/:id' and receive the complete object as JSON. I have the backend and it's working. I'm now trying to write the iOS client code.
Here's what I have:
After the code above is ran Restkit does not replace ':id: from the path with the ID attribute set in the Location object.
Do you guys have any ideas what I'm doing wrong?
UPDATE:
I had both request and response descriptors set for the Location class. I had a route added for the find_by_id request but it was a Named Route, not a Class Route. When I used the getObject:path:parameters:success:failure method the router did not fill in the 'id' placeholder (irregardless whether it was named 'id', 'object_id', 'identity' or whatever).
The solution I found is this:
- Continue using a Named Route but use the getObjectsAtPathForRouteNamed:object:parameters:success:failure method instead
- User a Class Route and continue using the getObject:path:parameters:success:failure method
The problem I was having was that when using a NamedRoute like so:
and then querying for objects using the getObject:path:parameters:success:failure method did not cause the router to fill out any placeholders in the URL path.
ios - Passing managedObjectContext via presentViewController
I am trying the "pass the baton" method for passing the managedObjectContext (MOC) thru multiple views. I have it successfully passed to the rootViewController. From there I move to a tabBarController via presentViewController
. I can't seem to find a way to pass the MOC when the tabBarController is pushed.
AppDelegate.m
The main view controller is basically a start up screen that will kick you into a login screen or if you are already logged in, to the tabBarController. Below is where I transition to the tabBarController from within the viewDidAppear
method.
MyViewController.m
The tabBarController in the storyboard has the identifier "mainTabVC".
I've tried lines like
but I get the error Property 'MOC' not found on object of type MyTabBarController even though I do have the property declared in MyTabBarController.h
Could someone show me a line of code that I can throw in this segue to push the MOC to the tab bar controller.
BTW- I'm utilizing RestKit in this app if that changes the way I should be handling this please let me know.
*****Solution********
To make things clear for any other new guys with the same question. I went from this:
To this:
Notice the assignment in the third line and using MyTabBarViewController instead of UIViewController in the second line. BIG thanks again to rdelmar!
ios - 使用 RestKit 0.20 对集合进行自定义请求映射
我正在尝试找到一种将对象集合正确映射到具有特定格式的 JSON 字典的方法。
我有一个具有以下接口(部分)的对象:
用户对象(部分)是:
目标是发布一个奖励对象以及接收者属性。
我可以想出一个适用于标题和评论属性的 RKObjectMapping,但接收器集合需要以下格式:
我的主要问题是如何将索引作为键插入。
我可以手动完成并调整 NSURLRequest HTTPBody,但我希望找到一种更干净/RestKit 的方式。
提前致谢。
ios - RestKit 0.20 忽略 putObject:映射
我正在尝试在没有映射的情况下将对象发送到服务器(PUT 请求),因为我已经从服务器获得了我需要的一切。即使服务器已成功创建对象,回调也会直接失败。
这是我正在做的一个例子:
服务器响应是 201 创建的,我可以在服务器中找到我的对象,所以这一切都很好,但是,回调直接触发失败,因为它正在尝试映射我的对象,失败回调中的错误是:
非常感谢,任何建议将不胜感激!
更新 1 现在添加了字典映射:
ios - RestKit 0.20 嵌套对象映射(对象树的路径不同)
我在映射嵌套对象值时遇到问题。
我有两个具有以下属性的对象:a)
b)
..so Profile 包含一个 Input 对象。当我用 RestKit (0.20) 映射对象时,我得到了一些东西。像这样:
我想要实现的是:
所以我不想映射“输入”,而只是映射 Input.value。这甚至可能吗?
目前我的代码如下所示:
编辑:(已解决)
好的,我解决了。希望这是人们应该这样做的方式。您可以直接从字典中寻址。