我有一个类似的方法:“performBlockAndWait:”块不执行
- (void)handleUpdate
{
dispatch_sync(dispatch_get_main_queue(), ^{
NSArray *objectIDs = [self.objectsInMainContext valueForKeyPath:@"objectID"];
[self.privateContext performBlockAndWait: ^{
// Some processing
}];
});
}
我叫mainContext
关联到主队列,并privateContext
关联到一个专用队列,是mainContext
的孩子。这种方法是从privateContext
的私有队列调用,而且它不是nil
达到performBlockAndWait:
呼叫时,但执行不进入块既不达到此方法后的任何代码...
我该怎么办在这里失踪?
在此先感谢
编辑:我得到在Xcode中没有错误,我已经在performBlockAndWait:
块内,调用此方法后代码中设置断点只是没有达到。
编辑2:我校正代码段,我没有访问mainContext
但关联到mainContext
对象的数组。
任何特定的原因,当你已经在私人环境中的第一个地方时,你为什么得到主要上下文来获取对象ID? – Mundi
@Mundi对不起,该行是错误的...我编辑问题 – AppsDev
@Mundi我需要将'mainContext'中的对象传递给这个子上下文来执行我的更新。 – AppsDev