Tag: restkit 0.20

RestKit – 与本地JSON文件同步数据库

我提供了一个示例JSON文件(用于testing目的,我没有提前访问Web服务)。 在加载文件和转换为NSDictionary ,我怎样才能使用该字典和同步我的数据库? 我读过的所有教程和示例都使用了Web服务 我已经创build了所有对象的映射并应用它们的关系。 一个例子: + (RKEntityMapping *) mapTableInManagedObjectStore:(RKManagedObjectStore *)managedObjectStore { RKEntityMapping *tableMapping = [RKEntityMapping mappingForEntityForName:@"Table" inManagedObjectStore:managedObjectStore]; tableMapping.identificationAttributes = @[@"tableID"]; [tableMapping addAttributeMappingsFromDictionary:@{ @"ID":@"tableID", @"TableNumber":@"tableNumber", @"NumberOfChairs":@"numberOfChairs"}]; return tableMapping; }

将上部键path映射到下部键path映射属性RESTKIT V0.20

"Allocation":{ "UserID":"8bc2df34-b77a-4889-a2ab-559e24cc2d40", "Answers": { "SurveyInstanceAnswerID":"cb924a6a-ad61-4786-b5fb-00302c4fc7dc", "SurveyInstanceAllocationID":"42e96cec-5a00-416c-8a96-488ab152e4f5", "AllocationUniqueRef":"1ce53cdf-b33e-4594-a938-b60656b8b64c", "SurveyContentID":"ccd07464-9718-4953-8e51-ad25fa00e053", "AnswerValue":null, } } 我有两个类与userID 分配和回答与answervalue和userID 。 我想映射userid在userid中的分配与答案类。 我正在使用rkEntitymapping来映射对象

RestKit:'NSInternalInconsistencyException',原因:'无法执行映射:没有`managedObjectContext`分配

我收到以下错误: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to perform mapping: No `managedObjectContext` assigned. (Mapping response.URL = https://www.someurl.com/lastrequest=2014-12-08T02%3A44%3A52Z)' 该应用程序停在RKResponseMapperOperation.m中的以下行: – (RKMappingResult *)performMappingWithObject:(id)sourceObject error:(NSError **)error { NSLog(@"managedObjectContext: %@, Source Object: %@ Error: %@", self.managedObjectContext, sourceObject, (*error).description); NSAssert(self.managedObjectContext, @"Unable to perform mapping: No `managedObjectContext` assigned. (Mapping response.URL = %@)", self.response.URL); …. 我注意到,在应用程序崩溃之前,上述方法被称为27(这个数字变化)。 在每个实例中,NSManagedObjectContext存在,即下面的行: 2014-12-07 […]

RestKit数据同步后本地删除问题

我使用RestKit作为应用程序的后端。 一切运作良好,但我遇到一个问题,提取本地删除后未经修改的数据。 这是匹配的path: [self.objectManager addFetchRequestBlock:^NSFetchRequest *(NSURL *URL) { RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern:@"cards"]; if([pathMatcher matchesPath:[URL relativePath] tokenizeQueryStrings:NO parsedArguments:nil]) return [NSFetchRequest fetchRequestWithEntityName:@"Card"]; return nil; }]; 当API响应缺less一个本地对象时,删除正确传播。 但是,如果执行本地删除,如下所示: for(NSManagedObject *entity in cards) { [RKManagedObjectStore.defaultStore.mainQueueManagedObjectContext deleteObject:card]; 如果再次执行/卡提取请求,如果在CoreData中刚被删除的对象没有改变,那么卡不会被更新。 直到应用程序重新启动或API响应中包含新对象之前,情况仍然如此。 即使服务器正在返回适当的JSON,RKMappingResult也是空的: 2013-07-03 17:58:00.732 Thanx[76837:c07] I restkit.network:RKHTTPRequestOperation.m:185 GET 'http://api.thanx-web.dev/v2/cards' (200 OK) [0.1086 s] 2013-07-03 17:58:00.734 Thanx[76837:c07] <RKMappingResult: 0xac9b080, results={ "<null>" = […]

Restkit嵌套映射有问题

我一直在试图创build一个login服务的请求,但我收到答复时有问题,我不知道我在做什么错。 这是我的代码: AppDelagate /* LOGIN RESPONSE */ RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[UserMapping class]]; [userMapping addAttributeMappingsFromDictionary:@{ @"_id":@"_id", @"name": @"name", @"lastname": @"lastname", @"username": @"username", @"password": @"password", @"repeatPassword": @"repeatPassword", @"age": @"age", @"gender": @"gender", @"photo": @"photo"}]; RKObjectMapping *loginResponseMapping = [RKObjectMapping mappingForClass:[LoginResponse class]]; [loginResponseMapping addAttributeMappingsFromArray:@[ @"code", @"message" ]]; [loginResponseMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"data" toKeyPath:@"data" withMapping:userMapping]]; RKResponseDescriptor *loginResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:loginResponseMapping method:RKRequestMethodPOST pathPattern:nil […]

RESTKit:两个终点POST,PUT,DELETE

我有两个EndPoints: http://rest.domain.com/invite http://rest.domain.com/template 根据用户select的选项,我需要能够在两个EndPoint上进行PUT , POST和Delete 。 所有三种方法的映射略有不同。 每个EndPoint的映射也不同。 什么是设置映射的最佳方法,以便它们被加载一次,并且可以针对每个EndPoint使用多次,具体取决于用户select的选项( PUT , POST或Delete )? 我必须在一个故事板上完成这个场景! 目前,下面是我在POST /invite EndPoint时使用的代码(在重映射后的第一个POST b / c之后崩溃): – (void)sendInvite:(NSInteger)methodType { AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; self.objectManager = [self getObjectManager]; self.objectManager.managedObjectStore = appDelegate.managedObjectStore; RKEntityMapping *invitationMapping = [RKEntityMapping mappingForEntityForName:kInvite inManagedObjectStore:self.objectManager.managedObjectStore]; RKEntityMapping *activityMapping = [RKEntityMapping mappingForEntityForName:kActivity inManagedObjectStore:self.objectManager.managedObjectStore]; Invite *invitation; switch (methodType) { […]

自定义标题每个请求在RestKit

我试图提交一个请求到服务器,使用RestKit 0.20.3需要不同的头取决于应用程序的一些状态 我读了这些post: question1 question2 他们不帮忙,因为这个api不可用 如何将自定义标题添加到RestKit的url请求?

RestKit 0.20发布数组Json问题

这是我需要发布到服务的json。 { "deviceToken":"asdfasdfasdf", "alarm": [ { "start" "8:30", "end": "9:30", "line": "156", "code": "xxxafsdfasdf", "station": "asdfa", "stationLeft": 5, "available": true, "times": 2 }] } 响应数据在报警中只有一个字段“id”: { "deviceToken":"asdfasdfasdf", "alarm": [ { "id":1, "start" "8:30", "end": "9:30", "line": "156", "code": "xxxafsdfasdf", "station": "asdfa", "stationLeft": 5, "available": true, "times": 2 }] } 然后我定义两个对象:DeviceAlarm对象: @interface DeviceAlarm : NSObject @property(nonatomic, […]

Restkit映射依赖关系

是否有可能使restkit中的映射相互依赖。 我有以下的JSON结构: { "IdList": [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ], “Persons”: [ { "Id": 2, "Name": “James”, "Description": “Tall”, "Items": [ { "Id": 1051, "Name": “Hat”, "Description": "", “Accesories”: [] } ] } ] } 我有2个响应描述符,以钻入数组IdList&Persons。 RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:[MappingProvider personsMapping] method:RKRequestMethodGET pathPattern:nil keyPath:@"Persons"statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; [self addResponseDescriptor:responseDescriptor]; RKResponseDescriptor *IdsResponseDescriptor […]

iOS:RESTKit与CoreData同步数据

设置:RESTFull API与MySQL数据库在后端。 我正在使用RESTKit v.20.3来进行API调用。 我即将切换到核心数据。 题: 如果我在远程数据库中有10个对象,并且第一次使用GET进行获取,我将把所有10个对象都取回并存储在Core Data中。 当我做出后续的提取请求时,我该如何告诉RESTkit只下载新的对象,而不是先前下载的对象? 最佳实践方法请!