restkit-0.20

RestKit 0.22 : how to map only firstObject of an array?

假如想象 提交于 2019-12-11 04:47:08
问题 I am receiving more data than needed: I only want to map first object of an array of objects. Using RestKit 0.22, how to map the following Json: { "name": "foobar", "tags": ["tag1", "tag2", "tag3"] } With the following model: @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *firstTag; To map name , I have this code: RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:@"MyObjectModel" inManagedObjectStore:[RKManagedObjectStore defaultStore]];

RestKit .20.x value transformation

强颜欢笑 提交于 2019-12-11 03:57:43
问题 I am new to iOS development and am trying to do some custom value transformation in RestKit, but I can't figure out how to do it. I have two current problems: I have a base64 encoded image that is returning in a JSON message from the server. It is in the below format. I am using Core Data as the backend persistent store and the 'image' field is stored in Core Data as binary data (NSData). When RestKit transforms the base64 encoded image into an NSData object, something goes wrong because the

Basic Authentication using Restkit

Deadly 提交于 2019-12-11 01:50:16
问题 I am trying to do Basic Authentication using RestKit but I need some help with figuring out why I get status code 401(Unauthorized). I tried this, but it did not work for me. I will appreciate if someone can point out my mistake. This is what my data looks like on the server side: Sample { "Id": "baec6f47", "TokenValidity": "00:00:00.1234567", "ValidTo": "2013-10-28T23:54:21.2934278+00:00", "Parameters": {}, "Token": "sample string 3" } I have a NSObject class called TokenObject, and that

RestKit CoreData 0.20.3 - additional check before saving the MOC after mapping finished

早过忘川 提交于 2019-12-11 01:21:08
问题 Is it any way to to add additional check to entity mapping? I have a returned object from the server with the same identification attribute and I need to check if last modified date is newer then my object stored in my local store. By default RestKit will overwrite my local instance if the identification attribute is the same. The mapping is done on a child context and I am trying to compare the new value from the server before the child context is saved back to parent but I can't find any

Delete Object in Restkit .20 did not take JSON Values

不羁的心 提交于 2019-12-10 22:19:34
问题 I have an API which is used to delete a record in server DB. I used to construct the API with the request ID .It was working with CURL, but in Restkit it seems to give an error. The Curl is: curl -d '{eve:{mod_policy:"current"}}' -X DELETE -H Content-Type:application/json https://myurl.com/eve/eve_id?token=my_aut_token\&apikey=myapi_key. I checked with POST & PATCH . It takes the JSON as a correct form. My RestKit Code Sample: RKObjectMapping *requestMapping = [RKObjectMapping requestMapping]

RestKit : Not able to perform mapping using coredata

杀马特。学长 韩版系。学妹 提交于 2019-12-10 22:05:29
问题 I'm using rest kit 0.20.3 and Xcode 5. Without core data I'm able to perform all rest kit operation, but when I've tried it with core data, I'm not even able to perform GET due to some problem. I can't figure it out. I'm new with core data. So pls help. Here is my code: AppDelegate.m @implementation CardGameAppDelegate @synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator =

RestKit valueTransformer not being called

流过昼夜 提交于 2019-12-10 20:03:54
问题 I am using RestKit to talk to my JSON endpoints. The endpoint returns a UNIX timestamp in 'number of milliseconds'. But RestKit's default transformer assumes that it is 'number of seconds' and I get a wrong value in NSDate. So I looked around, and found that I need to use a custom valueTransformer to tell RestKit how to transform my timestamp. Here's the code I have. + (RKBlockValueTransformer*) timeIntervalInMillisecondsSince1970TwoWayTransformer { return [RKBlockValueTransformer

Seeking recommendations for best RestKit/CoreData mapping and JSON structure for shallow routes

孤人 提交于 2019-12-10 18:55:29
问题 I'm developing a CoreData iOS app that's backed by a (Rails) REST API (that supports shallow routes). Because there are a lot of objects in the graph, I'd like the REST GETs to not to include a lot of nested results and, instead, just contain references that RestKit uses to establish (faulted) relationships. I'll then use shallow routes to request the individual (or groups of) objects as needed. Assuming I have a one-to-many (<-->>) data model such as A <-->> B, I have: RKEntityMapping *a

RestKit: how to fetch a simple JSON array of strings?

久未见 提交于 2019-12-10 16:27:38
问题 How should I use RestKit to fetch a JSON array of strings like this : ["Paris", "London", "Brussels", "New York"] I tried to make an object mapping but since there's no key path or attribute, I don't know what to map. I don't even need a mapping, the result could just be an array or a dictionary. Is there a way to achieve that? EDIT: For more info & solution : https://github.com/RestKit/RestKit/issues/1290 回答1: You need to create a mapping with a nil keypath. This instructs RestKit to

RESTKit: Comparing GET object with locally persisted before overwriting

﹥>﹥吖頭↗ 提交于 2019-12-10 10:34:20
问题 I have a saved object (persisted) in Core Data. Lets say below are the values: //Entity: employee objectID: 1111 firstName: @"Jon" lastName: @"D" modified: @"10:45PM" Now, I do a RKManagedObjectRequestOperation *operation request. I set operation.savesToPersistentStore = NO; and start the operation. The object was downloaded and it's been modified to the following: //Entity: employee objectID: 1111 firstName: @"Jonathan" lastName: @"Doe" modified: @"10:55PM" //I have 15 other properties that