Core data Restkit核心数据映射应用程序崩溃

Core data Restkit核心数据映射应用程序崩溃,core-data,ios6,restkit,Core Data,Ios6,Restkit,我正在将restkit响应映射到核心数据,但它使应用程序崩溃。我阅读了restkit核心数据映射文档,尽管我无法用restkit映射核心数据。 我想问几个问题。我还尝试了在restkit中使用的方法。但它也会使应用程序崩溃。但它造成了这样的混乱 1) 这对于使用restkit示例中使用的种子数据库是必要的吗? 2) 如何将响应直接映射到核心数据类? 这是我的密码 RKManagedObjectStore *objectStore = [[RKManagedObjectStore alloc]

我正在将restkit响应映射到核心数据,但它使应用程序崩溃。我阅读了restkit核心数据映射文档,尽管我无法用restkit映射核心数据。 我想问几个问题。我还尝试了在restkit中使用的方法。但它也会使应用程序崩溃。但它造成了这样的混乱

1) 这对于使用restkit示例中使用的种子数据库是必要的吗? 2) 如何将响应直接映射到核心数据类? 这是我的密码

  RKManagedObjectStore *objectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel: [NSManagedObjectModel mergedModelFromBundles:nil]];

[objectStore addSQLitePersistentStoreAtPath: [RKApplicationDataDirectory() stringByAppendingPathComponent:@"CoffeeShop.sqlite"] fromSeedDatabaseAtPath:nil withConfiguration:nil options:nil error:nil];
[objectStore createManagedObjectContexts];

RKObjectManager* objectManager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"https://api.foursquare.com/v2"]];
[objectManager setManagedObjectStore:objectStore];


RKEntityMapping* venueMapping = [RKEntityMapping mappingForEntityForName:@"Venue" inManagedObjectStore:objectStore];

[venueMapping addAttributeMappingsFromDictionary:@{
 @"name" : @"name",
 @"categories":@"prefix"}];

venueMapping.identificationAttributes=@[@"name"];

RKResponseDescriptor * responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:venueMapping
pathPattern:nil 
keyPath:@"response.venues"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:responseDescriptor];
这就是请求和检索数据

  RKObjectManager *objectManager=[RKObjectManager sharedManager];
  NSString *latLon = @"23.0280,72.5577";
  NSString *clientID = [NSString stringWithUTF8String:kCLIENTID];
  NSString *clientSecret = [NSString stringWithUTF8String:kCLIENTSECRET];
  NSDictionary *queryParams;
  queryParams = [NSDictionary dictionaryWithObjectsAndKeys:latLon, @"ll",    clientID, @"client_id", clientSecret, @"client_secret", @"coffee", @"query", @"20120602", @"v", nil];

 [objectManager getObjectsAtPath:@"venues/search" parameters:queryParams success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
 {
     NSLog(@"It Worked: %@",mappingResult.array);
     data=[[NSMutableArray alloc] initWithArray:mappingResult.array];
     NSLog(@"Data Counr%d",[data count]);
     // Or if you're only expecting a single object:
   //  NSLog(@"It Worked: %@", [mappingResult firstObject]);
     //[self.tableView reloadData];

 }failure:^(RKObjectRequestOperation *operation, NSError *error) {
     NSLog(@"It Failed: %@", error);
 }];
这是事故日志

2013-02-05 11:52:19.209 CoffeeShop[2715:11603] I restkit.network:RKHTTPRequestOperation.m:152 GET 'https://api.foursquare.com/v2/venues/search?client_id=U0JM2MAO3202LHDEGSJXOBNJODNWOFK2DS2F0IFDFJYQ2QAT&client_secret=5RNBGWHFWZRXSD4RCESRTIXR22KQSY2IEITAJ52NR1GMUP4F&ll=23.0280,72.5577&query=coffee&v=20120602'
 2013-02-05 11:52:20.863 CoffeeShop[2715:11603] I restkit.network:RKHTTPRequestOperation.m:179 GET 'https://api.foursquare.com/v2/venues/search?client_id=U0JM2MAO3202LHDEGSJXOBNJODNWOFK2DS2F0IFDFJYQ2QAT&client_secret=5RNBGWHFWZRXSD4RCESRTIXR22KQSY2IEITAJ52NR1GMUP4F&ll=23.0280,72.5577&query=coffee&v=20120602' (200 OK) [1.6540 s]
 2013-02-05 11:52:20.880 CoffeeShop[2715:12b03] -[__NSCFArray length]: unrecognized selector sent to instance 0xaa2fd90
 2013-02-05 11:52:20.881 CoffeeShop[2715:12b03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray length]: unrecognized selector sent to instance 0xaa2fd90'
 *** First throw call stack:(0x1dd1012 0x1bf6e7e 0x1e5c4bd 0x1dc0bbc 0x1dc094e 0x1c6196 0x1c54a2 0x2504d8 0x16a2fe3 0x23af3 0x23fdf 0x251d9 0x2645a 0x2cbff 0x162fd23 0x162fa34 0x17b7a 0x17462 0x1879d 0x19183 0x19a05 0x162fd23 0x162fa34 0x8310e 0x1e4d3f 0x250b014 0x24fad5f 0x24faaa3 0x1e4cba 0x81c91 0x7fc5f 0x162fd23 0x162fa34 0x16bc301 0x24f953f 0x250b014 0x24fc2e8 0x24fbfcb 0x9814fb24 0x981516fe)
 libc++abi.dylib: terminate called throwing an exception

提前感谢。

您无法识别的选择器错误可能会掩盖对僵尸的错误访问。我打赌根本原因与这个问题中发生的情况相同:


你可以看到我关于如何解决这个问题的答案。

在RK中看到过很多次。您为第三方框架支付的价格。您可以使用
nshtprequest
NSJSONSerialization
和核心数据来实现这一点,而无需更多的代码。因此,您建议我停止使用restkit,必须选择另一种方式。我建议这样做,是的。但也许你可以在同样使用RestKit的更小社区的帮助下找到解决问题的方法。