【发布时间】:2011-06-14 09:44:01
【问题描述】:
我在执行 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];
据我了解,在主线程中同步完成的 fetch 花费了太多时间,超过 10 秒,并且进程被挂起。
在互联网上浏览时,我发现了一个很好的解决方案来使获取异步:
http://blog.zssz.me/2010/01/asynchronous-fetch-in-core-data.html
但我想知道我的假设是否真的正确,以及是否有更简单的解决方案来解决这个问题。 非常感谢。
【问题讨论】:
标签: iphone core-data asynchronous crash request