本文介绍了NSManager的Setter创建_CDSnapshot_Provence_的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个NSManagedObject:

I have two NSManagedObject:


  1. DataEntered

  2. 普罗旺斯

它们之间有一个关系:DataEntered必须有一个普罗旺斯,普罗旺斯可能有一个/多个DataEntered。

There is a relation between them: DataEntered must have ONE Provence, and Provence may have one/multiple DataEntered.

一切运行正常,但使用仪器和分配时,每次将普罗旺斯设置为DataEntered时,在#Living中都会出现一个新的_CDSnapshot_Provence_:

All is working well, but when using Instruments and Allocations, every time I set the Provence to DataEntered, a new _CDSnapshot_Provence_ appears in #Living:

Provence * provence = [[self fetchedResultsController] objectAtIndexPath:indexPath];
[self.dataEntered setAddress_provence:provence];

DataEntered中的Provence的设置器由CoreData管理,没有自定义。

The setter for Provence in DataEntered is managed by CoreData, there is no customization.

当我保存DataEntered时,正确保存。什么可能导致多个生活的创建_CDSnapshot_Provence_?

When I save DataEntered, is saved correctly. What can cause the creation of multiple living _CDSnapshot_Provence_ ?

谢谢!

@class Provence;

@interface DataEntered : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, strong) Provence *address_provence;

@end


@class Provence;

@interface DataEntered : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, strong) Provence *address_provence;

@end



@class DataEntered;

@interface Provence : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSSet *dataEnteredAddress_Provence;

@end


@interface Provence (CoreDataGeneratedAccessors)

- (void)addDataEnteredAddress_ProvenceObject:(DataEntered *)value;
- (void)removeDataEnteredAddress_ProvenceObject:(DataEntered *)value;
- (void)addDataEnteredAddress_Provence:(NSSet *)values;
- (void)removeDataEnteredAddress_Provence:(NSSet *)values;

@end


#import "Provence.h"
#import "DataEntered.h"


@implementation Provence

@dynamic name;
@dynamic dataEnteredAddress_Provence;

@end 


推荐答案

I

请参阅Apple文档中的冲突检测和乐观锁定部分

See the section Conflict Detection and Optimistic Locking in the Apple docs athttps://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdChangeManagement.html

当Core Data获取对象从持久存储中获取,它获取其状态的快照。快照是对象的持久属性的字典,通常是对象的所有属性和与其具有一对一关系的任何对象的全局ID。

在同一链接上还有一个可用于阅读的部分 - 快照管理

There is also a section at that same link that is useful to read - Snapshot Management

我遇到的问题是Core Data在发生所有托管对象的错误或上下文重置后释放内存分配。

The problem I ran into was getting Core Data to release its memory allocations after I had faulted all the managed objects or did a context reset.

发布了关于此主题和相关主题的博客:
内核分配的核心数据问题 -

I just published a blog posting on this and related topics:Core Data issues with memory allocation - http://finalize.com/2013/01/04/core-data-issues-with-memory-allocation/

希望这有助于。

Scott

这篇关于NSManager的Setter创建_CDSnapshot_Provence_的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:08