Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Restkit 0.20对象在获得json响应后未映射_Iphone_Ios_Core Data_Restkit_Restkit 0.20 - Fatal编程技术网

Iphone Restkit 0.20对象在获得json响应后未映射

Iphone Restkit 0.20对象在获得json响应后未映射,iphone,ios,core-data,restkit,restkit-0.20,Iphone,Ios,Core Data,Restkit,Restkit 0.20,我正在使用RESTKit0.20。我试图从本地rails应用程序下载json响应,并将其保存到核心数据中。我试着跟随,一切都很顺利。 我想多次使用它,所以我将其作为基类(ListController)并将其子类化为SessionListController和EventListController。映射在AppDelegate.m中提供。 该应用程序有一个第一个viewcontroller,它是根控制器,始终映射响应,一切正常。但只要我更改viewcontroller,我就会得到响应,操作就会

我正在使用RESTKit0.20。我试图从本地rails应用程序下载json响应,并将其保存到核心数据中。我试着跟随,一切都很顺利。
我想多次使用它,所以我将其作为基类(ListController)并将其子类化为SessionListController和EventListController。映射在AppDelegate.m中提供。

该应用程序有一个第一个viewcontroller,它是根控制器,始终映射响应,一切正常。但只要我更改viewcontroller,我就会得到响应,操作就会停止。它甚至没有说映射是否已经开始。我不确定我错过了什么

我在这里初始化restkit

AppDelegate.m SessionViewController.m 完整代码位于

使用后

RKLogConfigureByName("RestKit", RKLogLevelWarning);
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);

我可以看到,我得到了正确的Http响应,但它没有被映射。我不知道为什么?

我刚刚将我的Restkit包更新为0.20.2。我现在没有面对这个问题。它应该在更新中修复。

日志是否说有时找不到响应描述符?或者没有匹配的关键路径?需要一些日志或示例JSON进行比较。不,日志中没有任何错误消息。它只是在记录响应文本后停止。事件的json响应示例是listApiFor的代码:-它返回什么路径?listApiFor返回事件的api路径-返回@“/api/v1/events”和会话返回@“/api/v1/sessions”定义响应描述符时,指定不带前导“/”的路径模式。很奇怪的是,在跟踪登录时没有日志信息,通常它会准确地告诉您问题所在。
@implementation ListController
- (void)viewDidLoad
{
[super viewDidLoad];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.managedObjectContext = appDelegate.managedObjectStore.mainQueueManagedObjectContext;
[self loadLocs];
[self.refreshControl beginRefreshing];
}

-(void)setModel:(Models)model{
if(self.model!=model){
    _model=model;
    self.title=[Model displayFor:self.model];
    _fetchedResultsController = nil;
    [self.tableView reloadData];
    [self loadLocs];
    [self.refreshControl beginRefreshing];
}
}

- (void)loadLocs
{
[[RKObjectManager sharedManager] getObjectsAtPath:[Model listApiFor:self.model]
                                       parameters:nil
                                          success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                                              [self.refreshControl endRefreshing];
                                          }
                                          failure:^(RKObjectRequestOperation *operation, NSError *error) {
                                              [self.refreshControl endRefreshing];
                                              UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An Error Has Occurred" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                                              NSLog(@"error: %@",error);
                                              [alertView show];
                                          }];
}


#pragma mark - Table View

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[[self fetchedRCforTableView:tableView] sections] count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section];
return [sectionInfo numberOfObjects];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
[self configureCell:cell atIndexPath:indexPath forTableView:tableView];
return cell;
}

#pragma mark - Fetched results controller
- (NSFetchedResultsController *)fetchedResultsController
{
if (_fetchedResultsController != nil) {
    return _fetchedResultsController;
}

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:[Model entityFor:self.model] inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

// Set the batch size to a suitable number.
[fetchRequest setFetchBatchSize:20];

// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:[Model sortDescriptorFor:self.model] ascending:YES];
NSArray *sortDescriptors = @[sortDescriptor];

[fetchRequest setSortDescriptors:sortDescriptors];

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:[Model displayFor:self.model]];
aFetchedResultsController.delegate = self;
self.fetchedResultsController = aFetchedResultsController;

NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error]) {
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
}
NSLog(@"_fetchedResultsController count %d",_fetchedResultsController.fetchedObjects.count);
return _fetchedResultsController;
}

@end
- (void)viewDidLoad
{
[super viewDidLoad];
self.model=Eventm;
// Do any additional setup after loading the view.
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.model=Sessionm;
// Do any additional setup after loading the view.
}
RKLogConfigureByName("RestKit", RKLogLevelWarning);
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace);
RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);