- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的情况是我的应用程序使用核心数据,并且需要从该核心数据加载图像以显示在表格 View 中。由于这样做需要时间,它需要在后台线程中运行。所以我有这样的代码:
dispatch_async(queue, ^{
if (self.cellInfo.numberOfMediaItems > 0) {
int i = 0;
int numberOfThumbnails = MIN(self.cellInfo.numberOfMediaItems, 3);
while (i < numberOfThumbnails) {
Media *media = [self.entry.media objectAtIndex:i];
UIImage *image = [media getThumbnail];
[self.mediaArray addObject:image];
i++;
}
}
dispatch_async(dispatch_get_main_queue(), ^{
self.isFinishedProcessing = YES;
[self setNeedsDisplay];
});
});
最佳答案
There is a golden rule when it comes to Core Data - one Managed Object Context per thread. Managed object contexts are not thread safe so if you are doing work in a background task you either use the main thread to avoid threading conflicts with UI operations, or you create a new context to do the work in. If the work is going to take a few seconds then you should do the latter to stop your UI from locking up.
关于objective-c - 后台线程和主线程同时访问核心数据时应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10819217/
有人可以向我澄清主线 DHT 规范中的声明吗? Upon inserting the first node into its routing table and when starting up th
我正在尝试使用 USB 小工具驱动程序使嵌入式设备作为 MTP 设备工作。 我知道 Android 从大容量存储设备切换到 MTP 设备已经有一段时间了,并且找到了 source code for M
我是一名优秀的程序员,十分优秀!