执行提取请求时崩溃
|
执行executeFetchRequest:error时发生崩溃:
MyApp[595]
具有超出允许时间的有效断言:
{(
<SBProcessAssertion: 0x1e5d1260> identifier: Suspending process: MyApp[595]
permittedBackgroundDuration: 10.000000 reason: suspend owner pid:29 preventSuspend
preventThrottleDownCPU preventThrottleDownUI
这是我的代码:
NSString *predString = [NSString stringWithFormat:@\"categoryId MATCHES \'%@\'\", categoryId];
NSPredicate *predicate = [NSPredicate predicateWithFormat:predString];
[request setPredicate:predicate];
NSError *error = nil;
NSArray* objects = [context executeFetchRequest: request error: &error];
据我了解,获取是在主线程中同步完成的,花费了太多时间,超过了10秒,并且进程被暂停。
在互联网上浏览时,我发现了一个不错的解决方案,以使异步获取:
http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html
但是我想知道我的假设是否正确,是否有更简单的解决方案。
非常感谢。
没有找到相关结果
已邀请:
2 个回复
babsoft
运算符用于SQL存储(您几乎肯定会使用它),因为sqlite不支持正则表达式。我希望它会出错而不是超时,但显然不会。 您想使用
甚至更好的
。如果您有一个称为“ 6”的属性,则通常表示该属性具有特定的唯一值,而不是具有很多小的变化的属性。使用
/
将产生更快的读取速度。
体悉