execute fetchrequest causes crash
来源:互联网 发布:软件测试的发展史 编辑:程序博客网 时间:2024/06/02 02:09
NSManagedObjectContext
is not thread safe. If you creating context on main thread
, then you can access the context only on the main thread
So you have to run the
executeFetchRequest
in the main thread, instead you can use performBlock
which will schedule it to run on its own thread.
//performblock将安排它运行在它自己的线程
- (NSArray *)executeFetchRequest:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context
{
__block NSArray *results = nil;
[context performBlockAndWait:^{
NSError *error = nil;
results = [context executeFetchRequest:request error:&error];
}];
return results;
}
performBlock won't work if you're initialising the context in the older
NSConfinementConcurrencyType
confinement model.
- execute fetchrequest causes crash
- BlocksKit UIEditUserWordController causes A2DynamicDelegate UITextField+BlocksKit crash
- execute
- crash
- CRASH
- crash
- Crash
- crash
- 23.1 Causes of exceptions
- Pixbuf causes memory leak
- Causes for disconnection
- Sealert causes memory leak
- What Causes Poor Availability?
- KAFKA源码阅读———处理ProduceRequest,FetchRequest
- There must be some causes!
- RewriteEngine causes 403 Forbidden error
- logfile switch causes incremental checkpoint?
- Beware of unknown root causes
- eclipse搭建Springmvc工程中容易出现的几个错误
- 锚点定位
- Linux命令进阶
- H264 Tutorial
- android起始页面与导航页面
- execute fetchrequest causes crash
- 复习数据结构和算法的好网站【python版】
- JAVA基础---集合(三)--List
- vw, vh, vmin, vmax
- Xcode下载地址
- [计蒜客简单题]为“A+B+C”的计算结果。
- JAlbum--一个像Windows资源管理器一样的web资源管理器
- 设计模式_组合模式(Java)
- React-Native中禁用Navigator手势返回