2011-05-13 5 views
0

이것은 xCode Editor에 의해 자동 생성 된 코어 데이터 용 내 GeneratedCode입니다.코어 데이터의 많은 관계로

#import <Foundation/Foundation.h> 
#import <CoreData/CoreData.h> 

@class Building, Category, City, District, Image, LatitudeLongitude, OpeningHour, Promotion, Rating, Review, URL; 

@interface Business : NSManagedObject { 
@private 
} 
@property (nonatomic, retain) NSString * Website; 
@property (nonatomic, retain) NSString * Email; 
@property (nonatomic, retain) NSString * Street; 
@property (nonatomic, retain) NSString * InBuildingAddress; 
@property (nonatomic, retain) NSString * Phone; 
@property (nonatomic, retain) NSString * Title; 
@property (nonatomic, retain) NSString * Zip; 
@property (nonatomic, retain) NSNumber * Price; 
@property (nonatomic, retain) NSSet* Promotions; 
@property (nonatomic, retain) Building * Building; 
@property (nonatomic, retain) NSSet* Categories; 
@property (nonatomic, retain) LatitudeLongitude * LatitudeLongitude; 
@property (nonatomic, retain) NSSet* Images; 
@property (nonatomic, retain) OpeningHour * OpeningHour; 
@property (nonatomic, retain) NSSet* Reviews; 
@property (nonatomic, retain) NSSet* URLs; 
@property (nonatomic, retain) Rating * Rating; 
@property (nonatomic, retain) NSSet* Districts; 
@property (nonatomic, retain) City * City; 

//이 3 줄을 추가했는데 왜 자동으로 생성 된 코드입니까?

- (void)addDistrictsObject:(District *)value; 
- (void)addCategoriesObject:(Category *)value; 
- (void)addReviewsObject:(Review *)value; 

@end 

모든 리뷰와 이미지를 "정리"하고 싶습니다.

self.Reviews = nil이 트릭을 수행합니까?

나는 self.LatitudeLongitude = nil을하는 것이 자기와 LatitutudeLongitude 사이의 관계를 삭제한다는 것을 안다.

답변

1

수정 - 삭제와 같이 "삭제"를 의미하는지 확인하십시오. 아래의 내 대답은 컨텍스트에서 사라지는 개체를 원한다고 가정합니다. 그냥

self.Reviews = nil; 

실제로 관리 개체 컨텍스트에 대한 귀하의 검토 개체를 삭제합니다 생각하지 않는 NSManagedObjects

사이의 관계를 단절하지. 즉, 각 하나에 해제 메시지를 보낼 것이지만, 세트의 각 하나에

[aContext deleteObject:reviewObj];

전화를 당신이 가지고있는 상황에서 삭제 할 수 있습니다. 위에 나열된 것처럼 "deleteObject"를 사용하여 비즈니스 개체 중 하나를 삭제하고 "Cascade"로 설정된 규칙 삭제 관계가 있다면 검토, 도시 등의 모든 개체가 발생한다고 생각합니다. 그 비즈니스 개체에 의해 소유 자동으로 삭제할 수 있지만 그 NSManagedObjects 삭제 될 발생할 알고있는 유일한 다른 방법입니다.

관련 문제