调用getsPermanentIDsForObjects时遇到线程错误 [英] Getting thread errors when calling obtainPermanentIDsForObjects

查看:177
本文介绍了调用getsPermanentIDsForObjects时遇到线程错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个新的NSManagedObject,并将其插入到并发类型私有队列的上下文中(因此它在后台线程上运行)。



在我保存之前,我称之为:

  [appDelegate .backgroundMOC getsPermanentIDsForObjects:
[NSArray arrayWithObject:newObject] error:& error];

然后我保存:

  [appDelegate.backgroundMOC save:& err]; 

但是,我得到一个EXC_BAD_ACCESS崩溃。看看stacktrace,我看到:

  0 semaphore_wait_trap 
7- [NSManagedObjectContentSave:]



我猜我的问题是 semaphore_wait_trap 不知道这是怎么造成的。



如果我注释掉行 getsPermanentIDsForObjects ,问题就消失了。 p>

任何想法?

解决方案

http://openradar.appspot.com/11478919 ),您需要将所有新创建的对象传递到 - [NSManagedObjectContext获取PermanentIDsForObjects:错误:]


I'm creating a new NSManagedObject and inserting it into a context with concurrency type private queue (so it runs on a background thread).

Right before I save, I call this:

[appDelegate.backgroundMOC obtainPermanentIDsForObjects:
       [NSArray arrayWithObject:newObject] error:&error];

Then I save:

[appDelegate.backgroundMOC save:&err];

However, I get a EXC_BAD_ACCESS crash. Looking at the stacktrace, I see:

0 semaphore_wait_trap
7-[NSManagedObjectContentSave:]

I'm guessing the problematic line is the semaphore_wait_trap, but I'm not sure how that's caused.

If I comment out the line obtainPermanentIDsForObjects, the problem goes away.

Any ideas?

解决方案

Due to a bug in obtaining object ids (http://openradar.appspot.com/11478919), you need to pass in all newly created objects to -[NSManagedObjectContext obtainPermanentIDsForObjects:error:].

这篇关于调用getsPermanentIDsForObjects时遇到线程错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆