views:

31

answers:

1

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 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?

A: 

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

Max Clarke