且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么nspredicate不工作

更新时间:2023-10-29 19:58:16

>不确定 [NSPredicate predicateWithFormat:@All]; 应该做,但它不太可能工作。当搜索文本更改时,您应该替换获取请求,并将新的获取请求添加到FRC。从FRC文档:

Not sure what [NSPredicate predicateWithFormat:@"All"]; is supposed to do but it's unlikely to work. When your search text changes you should replace the fetch request and add the new fetch request to the FRC. From the FRC docs:


initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:

initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:

重要提示:您不能在调用此方法后修改fetchRequest。例如,您不能更改其谓词或排序顺序。

Important: You must not modify fetchRequest after invoking this method. For example, you must not change its predicate or the sort orderings.

您的其他问题是FRC正在使用缓存。不支持在使​​用缓存时更改提取请求。一般建议是不使用缓存。如果你必须使用缓存某些原因,然后(之前)你改变获取请求,你还需要删除旧缓存 - deleteCacheWithName:)

Your other problem is that the FRC is using a cache. Changing the fetch request when using a cache is not supported. The general recommendation would be to not use a cache. If you have to use a cache for some reason then when (before) you change the fetch request you also need to delete the old cache - deleteCacheWithName:).

查看文档的FRCs 此处

See the docs for FRCs here.