crash on coredata ios8

后端 未结 4 1009
不知归路
不知归路 2021-02-12 12:32

I have a crash on CoreData when I save :

2014-09-16 09:51:58.273 My_app[2678:105246] *** Terminating app due to uncaught exception \'NSInvalidArgumentException\         


        
相关标签:
4条回答
  • 2021-02-12 12:45

    I'm also seeing this exact error on iOS 8 simulator and can't figure out what I'm doing wrong. I was able to work-around the issue by using @try/@catch but I'd rather understand where the conflict is or if I'm doing something wrong.

    @Ryan - do you have the apple issue/link you could post here? What about the sample project?

    0 讨论(0)
  • 2021-02-12 12:49

    Just to summarize the comments that helped me resolve this issue:

    • This seems to be a bug in Core Data related to Ordered Many-to-Many Relationships
    • If you have to keep the ordered option, there seems to be a workaround: make the relationship ordered both ways (thanks @Fabio Ritrovato).
    0 讨论(0)
  • 2021-02-12 12:54

    I saw the same issue and tried to apply the workaround mentioned by @knl. However, it seems that making the relationship ordered in both ways has a serious side-effect.

    I noticed that if I adjusted the order of relationships in one entity, it will mess up the order of relations in other objects of the same entity.

    Let's say we have two entities, Company and Employee. "Company" has a relationship "employees" to "Employee", which is an ordered to-many relationship. On the other hand, "Employee" has an inverse relationship to "Company" called "companies", which is also an ordered to-many relationship. (Initially Employee.companies was simply a to-many relationship, but later on I changed it to ordered to-many relationship as a workaround.)

    Now, assuming there are two Company objects, A and B, I found that if I change the order of objects in A.employees, the order of objects in B.employees will be affected as well. I need to mention that A.employees was adjusted in a private child context and when the child context was saved and thus the changes were pushed back to the parent context, B.employees was altered then.

    I added some logs and it seems that though the changes were made in A.employees only but it did trigger an global chain-effect. Core data integrated every object (X) in A.employees and removed all Company objects in X.companies and then added them back again in an arbitrary order, which caused the problem I am talking about.

    I don't know if this is a bug in core data or an designed behavior. If this a bug then probably I need to report it to Apple but if this an designed behavior, what is another workaround?

    0 讨论(0)
  • 2021-02-12 13:00

    some nsstring append a nil value

    0 讨论(0)
提交回复
热议问题