restkit

Do a simple json POST using RESTKit

核能气质少年 提交于 2019-12-17 18:28:52
问题 I'm new to iOS development and I'm having trouble making a simple Json POST request. I have a NSDictionary containing an user and password and I want to send those values as a Json to a server and get a response. I had that working without using restkit but I can't figure out how to accomplish the same using RestKit and just can't find a good example of what I want. - (bool) login{ NSMutableDictionary* params = [[NSMutableDictionary alloc] init]; [params setValue:self.email forKey:@"email"];

Restkit mapping for array with no keypath

隐身守侯 提交于 2019-12-17 17:04:04
问题 How can I create an object mapping for a JSON response like this, which is just an array of integers: [ 565195, 565309, 565261, 565515, 565292, 565281, 566346, 566347, 575241, 597230, 597231, 597227, 597228, 597229, 597232, 575248 ] 回答1: You need to perform a nil keypath mapping. Check the 'Mapping Values without Key Paths' section here. 来源: https://stackoverflow.com/questions/18004327/restkit-mapping-for-array-with-no-keypath

RestKit: How does one post an array of objects?

眉间皱痕 提交于 2019-12-17 09:30:53
问题 Question summary: Consider a class SyncObject that is KVC-compliant with properties such as: time , someValue , lastChange , uuid . Consider an NSArray containing exclusively instances of SyncObject . I need to submit the array to the server as a JSON array. How would one submit this array to the server using HTTP POST using RestKit? Example array: [ { "time": "14:45 10/21/2011", "someValue": "15", "lastChange": "14:45 10/21/2011", "uuid": "0b07c510-f4c8-11e0-be50-0800200c9a66" }, { "time":

Update RestKit 'lcl_RK.h' file not found in RKLog.h

爱⌒轻易说出口 提交于 2019-12-17 04:07:17
问题 I install RestKit v0.25.0 with CocoaPods v0.39 in Xcode 7.1 and have problem with imports. When I used CocoaPods v0.38.2 everything was amazing. "RKHTTPUtilities.h" file not found. It solves after set recursive in headers search path for "${PODS_ROOT}/Headers/Public/RestKit". But I get this error 'lcl_RK.h' file not found in RKLog.h. I also try do this. 回答1: I found only one not the best way. Add "$(PODS_ROOT)/RestKit/Vendor/LibComponentLogging/Core" in headers search path for project target.

Can't get RKPathMatcher *pathMatcher to match for deleting orphans objects

£可爱£侵袭症+ 提交于 2019-12-13 18:07:40
问题 I have the following mappings: RKResponseDescriptor *productionParametersPerEquipment = [RKResponseDescriptor responseDescriptorWithMapping:productionParameterMapping pathPattern:@"/api/rest/productionparameters/?equipment=:equipment_id" keyPath:@"objects" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; and then I have: [objectManager addFetchRequestBlock:^NSFetchRequest *(NSURL *URL) { RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern:@"/api/rest

Unable to store in Core Data from RestKit because of NSUnknownKeyException

和自甴很熟 提交于 2019-12-13 17:26:15
问题 I have a web service that returns data as such: {"facebook_friends":[{"name":"Jennifer","id":"38493"},{"name":"Sarah","id":"363"}, And here is my code: RKManagedObjectStore* objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:@"MyApp.sqlite"]; RKObjectManager* objectManager = [RKObjectManager objectManagerWithBaseURLString:@"http://192.168.85.128"]; objectManager.objectStore = objectStore; RKManagedObjectMapping *friendMapping = [RKManagedObjectMapping mappingForClass:[Friend

RestKit map XML element body

左心房为你撑大大i 提交于 2019-12-13 16:18:24
问题 How do I create a RestKit object mapping for an XML element body to an object attribute? XML: <response>ok</response> Mapping: RKObjectMapping *responseMapping = [RKObjectMapping mappingForClass:[Response class]]; [responseMapping mapKeyPath:@"???" toAttribute:@"body"]; 回答1: So if you want the string 'ok' in Response.body (who is an attribute of Response object) : [responseMapping mapKeyPath:@"response" toAttribute:@"body"]; It works ? 来源: https://stackoverflow.com/questions/9196947/restkit

RestKit - Post object and update its attributes

核能气质少年 提交于 2019-12-13 14:52:59
问题 I have a small app using RestKit with a Sinatra-backed server. When I post a user object to the server, the server successfully saves the user and responds with a json representation of the newly created user. Here's the code to create a user on the client: User *currentUser = [User currentUser]; currentUser.email = @"jacob@mail.com"; currentUser.firstName = @"Jacob"; currentUser.lastName = @"Morris"; currentUser.phone = @"2088956709"; currentUser.deviceId = @"MY-DEVICE-ID"; currentUser

iOS RestKit Date parsing

ぐ巨炮叔叔 提交于 2019-12-13 13:29:25
问题 In an old iOS project I had to parse dates that come in the format dd/MM/yyyy so I put these lines in a static method of my AppDelegate and it worked as expected // Set the Dateformatter for the Dates returned by Knowledge tt/mm/yyyy NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"dd/MM/yyyy"]; [[RKValueTransformer defaultValueTransformer] insertValueTransformer:dateFormatter atIndex:0]; However in the actual projects my dates come in a slightly

Custom headers per request in RestKit

╄→гoц情女王★ 提交于 2019-12-13 06:26:08
问题 I am trying to submit a request to the server,using RestKit 0.20.3 which needs different headers depending on some state of the application i read these posts : question1 question2 and they don't help, because this api is not available how do i add custom headers to RestKit's url requests ? 回答1: Question 2 is the correct technique, you just need to use the new API: request = [objectManager requestWithObject: method: path: parameters:]; Then create the operation: operation = [objectManager