views:

858

answers:

1

What is meant by mach_msg_trap error? I'm developing an application with core-data. I get this error when ManagedObjectContext if a different thread is "used" the second time. I've a producer consumer kind of threading system. The producer thread and the consumer thread uses the same underlying sqlite db, but different managedobjectContext as they are on different threads. But I want the producer thead to check new data and if any, i want it to update my managedObjectContext. But the second time it runs the app crashes giving the above result.

Please help...

+3  A: 

mach_msg_trap is a function, not an error. Specifically, it's the function that the run loop calls to wait for something to arrive. That function is how your application can wait for something to happen (I/O completes, timer fires, something posts a notification, etc.) without using CPU time.

But I want the producer thead to check new data and if any, i want it to update my managedObjectContext.

I'm not a Core Data guy, so I don't know the specific solution, but I do know that you never send a message to another thread's MOC. You are right to have separate MOCs, and you have them for a reason.

I suggest you edit your question to clarify that you are asking how to signal one Managed Object Context that another Managed Object Context has changed the data store that both of them share. Your question really has nothing to do with mach_msg_trap.

Peter Hosey