It does not appear that you have a dataSource. You need to implement: - (int)numberOfRowsInTableView:(NSTable View *)aTableView ; - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
- Sean On Sun, Sep 20, 2009 at 4:51 PM, Colin Howarth <co...@howarth.de> wrote: > Hi all, > > I've tried various searches, Apple documentation and example code, but my > code stubbornly refuses to work :-( > > I'm trying to do this in conjunction with Interface Builder... > > > I have an instance of an NSMutableArray of LensElements in my AppDelegate. > > I have an NSArrayController in the MainMenu.xib IB window. > > My main window has an NSTableView. > > I'd like the NSTableView to display the data of the array of LensElements. > Later I'd like to be able to drag elements within my custom LensView, and > have this update the TableView. Also, changing data within the TableView > should update the LensView. But, for now, I'd be happy if the Table would > simply display the data. (grrrr) > > It's really frustrating. The examples I find either don't seem to fit what > I'd like to do (NSMutableArray - NSArrayController - NSTableView). And/or > they use ancient versions of IB (which keeps changing). Or they don't use IB > at all. Or, like me, they just mention some settings, but ignore others - > like "Table View Attributes >> Control >> State: Enabled" or "Array > Controller Attributes >> Object Controller >> Editable (yes)". Sometimes I > see columns bound. Sometimes ControllerKey is "selections" sometimes it's > "arrangedObjects". And nothing works. The documentation only makes sense > when you know exactly what it's talking about. :-( > > > Please unconfuse me. I only need to get "into" this once, then I'll be OK. > Honest. > > > > In Interface Builder: > > ################################################################### > > Trace App Delegate Connections: > Referencing Bindings: > elements --- Content Array / Array Controller > > > ################################################################### > > Table Column (position) Attributes: > Table Column: > Title: Z position > Identifier: position > > Table Column (position) Bindings: > Value: > Bind To: Array Controller > Controller Key: selection // tried > arrangedObjects > Model Key Path: position > > Table Column (position) Connections: > Bindings: > Value -- Array Controller / selection.position > > ################################################################### > > Array Controller Attributes: > Object Controller: > Mode: "Class" > Class Name: "LensElement" > > Array Controller Bindings: > Controller Content: > Bind To: Trace App Delegate > Model Key Path: elements > > Array Controller Connections: > Bindings: > Content Array --- Trace App Delegate / elements > Referencing Bindings: > selection.position --- Value / Table Column (position) > selection.radius --- Value / Table Column (radius) > > ################################################################### > > > Here are the snippets of code (#imports etc included). > > The app compiles without errors or warnings and runs fine. All my views and > buttons etc show up fine, but the NSTableView doesn't show any content. > Well, it did once, when there was only one LensElement in the array :-) I > then added another, as you can see below, and it stopped showing anything. I > removed it again and it hasn't worked since... (???) > > > ### LensElement.h #################################################### > > @interface LensElement : NSObject > { > NSNumber *position; > NSNumber *radius; > } > > @property (copy, nonatomic) NSNumber *position; > @property (copy, nonatomic) NSNumber *radius; > > @end > > ### LensElement.m #################################################### > > @implementation LensElement > > @synthesize position; > // creates the proper getter and > setter methods? > @synthesize radius; > > @end > > ### TraceAppDelegate.h# ############################################### > > @interface TraceAppDelegate : NSObject <NSApplicationDelegate> { > NSWindow *window; > NSMutableArray *elements; > NSArrayController *ctrlr; > } > > @property (assign) IBOutlet NSWindow *window; > @property (assign) NSMutableArray *elements; > > @end > > ### TraceAppDelegate.m ############################################### > > @implementation TraceAppDelegate > > @synthesize window; > // creates the proper getter and setter > methods? > @synthesize elements; > > - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { > > LensElement *element = [[LensElement alloc] init]; > // this is just for testing... > LensElement *element2 = [[LensElement alloc] init]; > > elements = [[NSMutableArray alloc] initWithObjects:element, > element2, nil]; > > [element setValue: [NSNumber numberWithDouble: 5.0] forKey:@ > "position"]; > [element setValue: [NSNumber numberWithDouble: 10.0] forKey:@ > "radius"]; > > [element2 setValue: [NSNumber numberWithDouble: 6.0] forKey:@ > "position"]; > [element2 setValue: [NSNumber numberWithDouble: -15.0] forKey:@ > "radius"]; > > NSLog(@"pos: %@", [[elements objectAtIndex:1] valueForKey:@"position"] > ); // prints 6.0, as it should > > ... > #################################################################### > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/skline1967%40gmail.com > > This email sent to skline1...@gmail.com > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com