NSManagedObjects that I own being released by main.m?

前端 未结 2 355
梦如初夏
梦如初夏 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: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.

提交回复
热议问题