Is there a way we can give dummy input to restkit?

偶尔善良 提交于 2019-12-24 08:14:30

问题


I am pretty new to the Restkit. I know how my restful response will be. Its not ready yet to get from the server side. Is there a way to give dummy input directly to restkit ? We can give json text file as an input to NSUrlConnection, similarly how to do it here?


回答1:


I have been able to do this is

- (RKObjectMappingResult*)mapResponseWithMappingProvider:(RKObjectMappingProvider*)mappingProvider toObject:(id)targetObject error:(NSError**)error {

in RKObjectLoader.m

where I optionally read a static json text file and replace the bodyAsString. If you look at

[self.URL description]

you can scan the URL and maybe read a test file based on the request url




回答2:


How about running a simple web server which will return any output you want in JSON format? For example, when I need to prototype an app which will use RestKit, I create a simple ruby app using sinatra web framework (few lines of code) and start it locally, and point my RestKit based app to web app (http://www.sinatrarb.com)



来源:https://stackoverflow.com/questions/13342253/is-there-a-way-we-can-give-dummy-input-to-restkit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!