Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

klaxamazoo

macrumors 6502
Original poster
Sep 8, 2006
438
0
I've been trying to figure out how to update some tableViews that are controlled using NSArrayControllers.

Big Picture:
I am writing a program to help me organize a bunch of measurements I'm am taking on my experiment's samples. Each experiment has multiple samples with multiple sections and each section contains multiple measurements of multiple areas. Things were getting out of control with way too many excel files.


Set up:
- I have a multi-level set of NSMutableArrays. i.e. Array_1 consists of objects that also have an Array_2 with objects with arrays. I have written some methods that create new objects and fill the arrays with the correct information.

- The NSArrayControllers' bindings are set in IB and I have verified that they are set correctly by initializing a number of arrays/objects and filling the tables with these initial objects. These objects show up, but none of the objects after that.

- The objects are added to the arrays using [arrayName addObject: newObject] method from within the object.

- All the objects, arrays and sub-arrays use the following @property
Code:
@property (nonatomic, copy) NSString	*eblTestNumber;
@property (copy, nonatomic) NSMutableArray *sampleGroupArray;


Problem:
The tableViews are not updated when I add objects to the array

Attempted Solutions:
- I've looked at the documentation for NSArrayControllers but I can't find a reload data option or anything similar.
- I've tried adding [self willChangeValueForKey: @"eblTestArray"] and [self didChangeValueForKey: @"eblTestArray"] calls to the routine and the program freezes but there isn't any information in the console.
Code:
 [self willChangeValueForKey: @"eblTestArray"];
        NSLog(@"START: willChangeValueForKey");
        [eblTestArray addObject: newEBLTest];
        [self didChangeValueForKey: @"eblTestArray"];
        NSLog(@"END: willChangeValueForKey");

- I've tried calling reloadData on the tableViews but that doesn't update the table
- I've verified that the objects were added to the array.
- I made an IBOutlet NSArrayController and connected it in IB to my AppDelegate.


I know that the NSArrayController has an "add:" option in the "Received Actions" but I'm trying to update a large number of arrays and sub-arrays. In my previous projects I built my own TableView controllers but I would like to use KVC and the NSArray controllers.


Questions:
- Should I be adding the objects to the arrays and sub-arrays using a different method? i.e not [array addObject: newObject]
- Should I add objects directly through the ArrayController?
- Is there something simple (or complex) that I'm missing?

Thanks for any help,
Owen
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.