restkit

Send JSON request with Restkit RKParams

僤鯓⒐⒋嵵緔 提交于 2020-01-04 02:16:09
问题 I need to send a JSON request to a REST service. I'm using Restkit RKParams to send a request. Currently it works as follows: [params setValue:@"-46.566393" forParam:@"checkin[lng]"]; [params setValue:@"-23.541576" forParam:@"checkin[lat]"]; Send: { "checkin": { "lng":"-26.566393", "lat":"-63.541576" } } Now I want to form JSON data like this (with few more items): { "checkin": { "lng":"-26.566393", "lat":"-63.541576", "votes": [ {"vote_id":28}, {"vote_id":11} ] } } How would I set the params

Using RestKit to perform a synchronous request

雨燕双飞 提交于 2020-01-04 01:58:15
问题 - (BOOL)do_a_Restkit_request_and_return_a_boolean { [manager postObject:nil path:@"/mypath" parameters:@{@"password":password} success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) { myResult = [mappingResult firstObject] == 5; } failure:^(RKObjectRequestOperation *operation, NSError *error) { }]; return myResult; } Hello I would like to make a RestKit call like the above Synchronous so as to return myResult after the call of the Success block. 回答1: You can use an

RestKit Relation Mapping Many to Many Core Data relationship fault error

时光毁灭记忆、已成空白 提交于 2020-01-03 04:32:20
问题 I am using RestKit to map the following JSON to core data. I have a many-to-many relationship set up in core data. A hopper can have many users and a user can have many hoppers. I am getting this error message: (entity: Hopper; id: 0x767d240 hopperToUsers = <relationship fault: 0x8352960 'hopperToUsers' ; So none of my users are being updated. The json: { "hoppers": [{ "bearing": 0, "created_at": "2013-07-26T07:57:00Z", "distance": 0.0, "id": 4, "lat": "30.422032", "lng": "-86.617069", "name"

Iphone app archive - No such file or directory

≯℡__Kan透↙ 提交于 2020-01-03 03:13:07
问题 I am almost ready to release my iphone app. I use restkit for consuming my webservice. When I archive, it fails with this error: cp: /Users/myusername/Library/Developer/Xcode/DerivedData/project-name-/ArchiveIntermediates/project-name/IntermediateBuildFilesPath/UninstalledProducts/include/RestKit: No such file or directory I dragged & dropped restkit into the project. It builds and works fine in debug mode. I am guessing it is unable to locate restkit dir while archiving. But I am not sure

RestKit JSON null value crash

我是研究僧i 提交于 2020-01-02 05:23:06
问题 I have this problem. I am developing app in Swift and using RestKit to retrieve and post data back to API. However I have hit road block. If retrieved JSON payload contains some null value, the app wil crash with message: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x1994faba0' What do I do? The mapped properties are Strings. Mapped object: public class User: NSObject { public var id: Int? = 0

How do I have two post routes for the same class in RestKit

随声附和 提交于 2020-01-01 03:36:12
问题 Since I couldn't figure out how to set up two different POST resource paths for the same class , I tried manually creating the RKObjectLoader request but it seems to keep sending a GET request instead of a POST even though I've set the method to POST. Here is my code User *user = [[User alloc] init]; user.uname = uname; user.pwd = pwd; RKObjectManager *svc = [RKObjectManager sharedManager]; RKObjectMapping* mapping = [svc.mappingProvider objectMappingForClass:[User class]]; // what I was

RestKit - Send added/edited/deleted objects after offline storage

浪尽此生 提交于 2020-01-01 03:31:11
问题 Using RestKit with Core Data I'm providing offline support when the user adds, edits or deletes objects without an internet connection by flagging the objects and saving them with Core Data. If the internet is available again, I'll fetch all added/edited/deleted objects, save them in arrays and right know use the normal methods and loop for each item to put them on the server. List of arrays - fetchedAddedCompanies - fetchedEditedCompanies - fetchedAddedContacts - fetchedEditedContacts -

How do I use basic auth with RestKit's getObject?

主宰稳场 提交于 2019-12-31 16:46:19
问题 I tried the following to set the basic auth username and password, but it does not seem to be passing the basic auth in the request.. secureManager = [[RKObjectManager objectManagerWithBaseURL:@"http://localhost:3000"] retain]; secureManager.client.username = uname; secureManager.client.password = pwd; RKObjectLoader *loader = [svc getObject:user delegate:self]; loader.userData = [NSNumber numberWithInt:RequestLogin]; UPDATE: found my problem, I needed to add the following snippet

“libRestKit.a, file was built for archive which is not the architecture being linked (armv7)”

荒凉一梦 提交于 2019-12-31 03:24:21
问题 I'm trying to use xcodebuild to build a project, but RestKit and GPUImage are giving issues below: ld: warning: ignoring file /project/libGPUImage.a, missing required architecture armv7 in file /project/libGPUImage.a (2 slices) ld: warning: ignoring file /project/libRestKit.a, file was built for archive which is not the architecture being linked (armv7): /project/libRestKit.a Please help! 回答1: Set Build Active Architecture Only to NO for static Library in project target setting. 回答2: I guess

ASIHTTPRequest backed RestKit object mapping

不问归期 提交于 2019-12-30 11:10:54
问题 We must support some old code that runs using ASIHTTPRequest, but we want the object mapping and core data support provided by RestKit. Does anyone know of any way of "gluing" these two together? I picture using ASIHTTPRequest for the requests and someone manually forwarding the payload over to RestKit. 回答1: Ok, so this wasn't too hard after all. Here is a class I wrote just for this (no disclaimers, it works for us and may be useful for someone else). You can use this as a direct replacement