ios - CoreData合并冲突与单个上下文
<p><p>我无法解决一个看起来太愚蠢而无法存在的问题。我有一个使用 CoreData 生成对象的 UITableView。</p>
<p>我在 处返回错误:</p>
<pre><code>if (editingStyle == UITableViewCellEditingStyleDelete) {
NSManagedObjectContext *context = ;
Stop *stop=;
;
NSError *error = nil;
if (!) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, );
</code></pre>
<p>当我传递停止对象和上下文时(通过对 <strong><em>;</em></strong> 的新调用返回另一个 View 并像这样保存它:</p>
<pre><code> Stop *object= [ objectAtIndexPath:indexPath];
[ setStop:object];
[ setContext:];
</code></pre>
<hr/>
<pre><code>-(void)viewWillDisappear:(BOOL)animated
{
NSError *error = nil;
self.stop.locationText=self.textLocationField.text;
;
if (!) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, );
</code></pre>
<p>该错误是一个 NSMergeConflict,据我了解,当多个 MOC 对同一数据进行操作时会发生此错误。但我一定错过了一些基本的东西,因为我不相信我有两个上下文。我不是在一个上下文中简单地创建、修改和删除对象吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>经过大量试验和错误后,当您没有定向关系时,您会遇到 NSMergeConflict。因此,如果您有一个人有脚,那么您的脚必须指向关系图中的一个人。</p></p>
<p style="font-size: 20px;">关于ios - CoreData合并冲突与单个上下文,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24847500/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24847500/
</a>
</p>
页:
[1]