NSManagedObjects that I own being released by main.m?

前端 未结 2 356
梦如初夏
梦如初夏 2021-01-13 15:02

First, in my root view controllers viewDidLoad, I initialize an NSDictionary with arrays of NSManagedObjects, like so:

- (void)viewDidLoad {
    [super viewD         


        
相关标签:
2条回答
  • 2021-01-13 15:28

    Rerun your program with the environment variableNSZombieEnabled set to YES. That will tell you when you're double releasing the object, and what object it is. Alternatively, you can debug this in Instruments using the Zombies tool.

    0 讨论(0)
  • 2021-01-13 15:39

    self.tips hasn't been released; the Tip returned by [self.tips objectForKey:categoryNameString] has. It's returning a fault, not an object. Core Data will automatically fault objects when necessary.

    Try putting this in when defining your NSFetchRequest:

    [fetchRequest setReturnsObjectsAsFaults:NO];
    

    This is what is going on: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdFaultingUniquing.html, if you want to learn more about it.

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