Basic data: -deleteObject: crashes, do the rules eliminate the cause?

I have the following model, as you can see in the image.

alt text http://img521.imageshack.us/img521/9741/schermata20100224a12251.png

My application requires updating each instance of B, so for each viewWillAppearI need to delete all B in the model. When B is deleted, the cascade deletion rule in relation to C will delete all C, and then the cascade to all D. A and E are constants.

I have a DeleteRule for each object as follows:

A: b - Cascade
B: c - Cascade, a - Nullify
C: b - Nullify, d - Cascade
D: c - Nullify, e - Nullify
E: d - Cascade

or

A -(cascade)->> B -(cascade)-> C -(cascade)->> D -(nullify)-> E
A <-(nullify)- B <-(nullify)- C <-(nullify)- D <-(nullify) E

B, C, D. fetchRequest B A, -deleteObject: B ObjectContext. EXC_BAD_ACCESS [managedObjectContext save: & ].

- , ? DeleteRule ? B, C, D?

:

:

  #0    0x01d843ae in ___forwarding___
  #1    0x01d606c2 in __forwarding_prep_0___
  #2    0x01c618b6 in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]
  #3    0x0003263a in _nsnote_callback
  #4    0x01d4f005 in _CFXNotificationPostNotification
  #5    0x0002fef0 in -[NSNotificationCenter postNotificationName:object:userInfo:]
  #6    0x01bc217d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:]
  #7    0x01c21763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:]
  #8    0x01ba65ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:]
  #9    0x01bdc728 in -[NSManagedObjectContext save:]

, NSZombieEnabled MallocStackLogging YES:

  2010-02-24 15:41:39.803 Foo[2591:207] deleting object: FUM5
  2010-02-24 15:41:40.515 Foo[2591:207] *** -[viewController controllerWillChangeContent:]: message sent to deallocated instance 0x7e54510

2: SOURCE ADDED

, . . README. , .

+3
2

NSFetchedResultsControllerDelegate? , , - . UITableView, . - NSManagedObject, NSManagedObjectContext , , .

objc_exception_throw, .

Update

, B, A B. . , .

+2

, C D. , :

  • C D.
  • C D.

- C, , , . D , EXC_BAD_ACCESS. ( E D, )

,

  • C → D , .
  • , C → D, , .
  • , , , . , C D , . , .
  • , B. B Cs . , , , , .

Edit01:

, .

, "b" A . B, :

2010-02-24 16:14:02.064 CoreDataTestDeleteRule[20887:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=1580 UserInfo=0x3d0b450 "Operation could not be completed. (Cocoa error 1580.)"
2010-02-24 16:14:06.340 CoreDataTestDeleteRule[20887:207] Unresolved error Error Domain=NSCocoaErrorDomain Code=1580 UserInfo=0x3d19980 "Operation could not be completed. (Cocoa error 1580.)", {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1580.)";
    NSValidationErrorKey = b;
    NSValidationErrorObject = <A: 0x3b2faf0> (entity: A; id: 0x3d05330 <x-coredata://6870AF7C-E28F-4B4E-80AB-09C648651179/A/p1> ; data: {
    b =     (
    );
    name = a;

(BTW, Core Data CoreDataErrors.h.)

, A, b, b. A → > B .

. . , B.h :

#import <CoreData/CoreData.h>

@class A;

@interface B :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) A * a;
@property (nonatomic, retain) NSManagedObject * c;

@end

:

#import <CoreData/CoreData.h>

@class A;
@class C;

@interface B :  NSManagedObject  
{
}

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) A * a;
@property (nonatomic, retain) C * c;

@end

, .

. Objective-c - . , . (, ) : , , , , ..

, B ↔ C ↔ > D , . " ". .

+3

Source: https://habr.com/ru/post/1734232/


All Articles