为什么此提取请求不返回任何内容

ICL1901

我正在尝试过滤一些托管对象。结果虽然是zip。

过滤器为“名称”。名称是由根视图提供给此详细信息视图的元素。名称记录确定:

[48582:2754928] name: To Be
[48582:2754928] predicate: name == @"name"

name = [self.detailItem valueForKey:@"name"];

NSError *error;
    if (![[self fetchedResultsController] performFetch:&error]) {
        // Update to handle the error appropriately.
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        exit(-1);  // Fail
    }

FetchResultsController如下:

 NSError *error = nil;
    name = [self.detailItem valueForKey:@"name"];
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"VerbEntity" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];
    predicate = [NSPredicate predicateWithFormat:@"name == %@",@"name"];
    NSLog(@"name: %@", name);
    fetchRequest.predicate = predicate;
    NSLog(@"predicate: %@", predicate);

 // Create the sort descriptors array.
    NSArray *sortDescriptorArray = nil;

    //  Declare sort descriptors
    NSSortDescriptor *sortDescriptorPrimary = nil;




    sortDescriptorPrimary = [[NSSortDescriptor alloc] initWithKey:@"position" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];

    //  Set sort descriptor array
    sortDescriptorArray = @[sortDescriptorPrimary];

    //  Apply sort descriptors to fetch request
    [fetchRequest setSortDescriptors:sortDescriptorArray];

   NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];

    NSLog(@"fetchedObjects count: %lu", (unsigned long)fetchedObjects.count);   
    _fetchedResultsController.delegate = self;   
    return _fetchedResultsController;
}

有什么特别突出的吗?谢谢你的帮助。

迈克·威尔士

似乎您的_fetchedResultsController没有设置获取请求。也许不只此代码段显示了...但这可能行得通

NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"VerbEntity"];
request.predicate = [NSPredicate predicateWithFormat:@"name == %@",@"name"];

// Note: Sort descriptors available depend on the backing store type.
NSSortDescriptor *sortDescriptorPrimary = [[NSSortDescriptor alloc] initWithKey:@"position"        
                                                                      ascending:YES 
                                                                       selector:@selector(localizedCaseInsensitiveCompare:)];

request.sortDescriptors = @[sortDescriptorPrimary];

// The request needs to be set on the controller.
NSFetchedResultsController *controller =
    [[NSFetchedResultsController alloc] initWithFetchRequest:request
                                        managedObjectContext:self.managedObjectContext
                                          sectionNameKeyPath:nil
                                                   cacheName:nil];
// The controller needs to perform the fetch.
[controller performFetch:nil];  // Optionally pass in an NSError.
controller.delegate = self;
_fetchedResultsController = controller;
return controller;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

main函数不返回任何内容。为什么?

为什么我的内部联接查询不返回任何内容?

为什么此流不返回任何元素?

为什么此正则表达式查询不返回任何结果?

NLTK关系提取不返回任何内容

MongoDB GET请求不返回任何内容

为什么此处理程序不返回任何内容?

为什么python在计算后不返回任何内容?

为什么.map()不返回任何内容?

为什么Swift的类型检查系统允许返回类型的函数不返回任何内容?

为什么SQL不匹配任何内容?

Ajax请求不返回任何内容。为什么?

为什么PIG FILTER不返回任何内容?

为什么OpenGL方法不返回任何内容?

为什么调用存储过程不返回任何内容?

Mongoose.findOne不返回任何内容,为什么?

为什么在循环内时此Mongo查询不返回任何内容,但循环的主体起作用?

为什么此迭代没有返回任何内容?

为什么scanf()总是不返回任何内容?

为什么mycourses [i] .getGrade()不返回任何内容(C ++)?

请求不返回任何内容

如果javascript中的函数不返回任何内容,为什么?

为什么 dask 在 CUDA 函数上不返回任何内容?

为什么我的 for 循环不返回任何内容?

FutureBuilder 快照数据不返回任何内容,为什么?

为什么在搜索存在的类时不返回任何内容?

为什么 .map 函数在反应中不返回任何内容

获取请求不返回任何内容

为什么类中的函数不返回任何内容?