开发者

Problem with NSManagedObjectContext crashing app

I have a navigation based app that uses Core Data for storage. The schema for this particular section is as follows:

Scene hasMany Tasks hasMany DeviceCommands

Tasks also have many other objects besides DeviceCommands (like DelayCommands etc), but this is beyond the scope of the problem (I开发者_Go百科 think).

DeviceCommands also link to a parent object as follows:

Device hasMany DeviceCommands

Now, the user can create a new Task, which pops up a modal view to select the Device. When you select a device, a tableview is pushed with the DeviceCommands that belong to the Device. When you select a DeviceCommand, it assigns it to the Task with task.deviceCommand = device.deviceCommand. For some reason, and this only happens in this section of the app, the app crashes with the following output in the console:

2010-10-26 15:37:33.337 livOS4[47226:207] Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. * -[NSMutableArray objectAtIndex:]: index 35 beyond bounds [0 .. 0] with userInfo (null)

Index 35 refers to the index of the DeviceCommand in the UITableView and NSFetchedResultsController. Through a process of trial and error I've discovered that the NSMutableArray is the array with the Devices. If I add a new Device to the app, the array bounds are [0 .. 1].

I added an observer for NSManagedObjectContextObjectsDidChangeNotifications but it crashes before the observer receives anything.

Can anyone help or offer any advice for fixing this?


I have the same problems with NSFetchedResultsController.

Problem disappear then I add this to my viewController

- (void)dealloc
{
    self.fetchedResultsController.delegate = nil;
    self.fetchedResultsController = nil;
}


Fixed it this morning. Turned out to be a problem with how I was assigning the NSFetchedResultsController delegate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜