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

2019-07-28 17:38发布

问题:

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)



标签: ios restkit