0

I have been able to successfully bind my view to an NSCollectionView, however my model is not binding to the view itself correctly. My model contains a few properties:

@interface MPReportBuilderCustomReportFilter : NSObject


@property (assign) MPReportBuilderTableColumnRecord *column;
@property (assign) NSString *columnName;
@property (retain) NSMutableArray *dataArray;
@property (assign) NSArrayController *dataArrayController;

-(id)initWithTableColumn:(MPReportBuilderTableColumnRecord *)column;
-(void)loadDataArray;

@end

I was able to programmatically bind an array controller in my model class and it would bind successfully to the data array:

@implementation MPReportBuilderCustomReportFilter

-(id)initWithTableColumn:(MPReportBuilderTableColumnRecord *)column
{
    self = [super init];
    if (self) {

        self.column = column;
        self.columnName = self.column.columnName;
        self.dataArray = [[[NSMutableArray alloc] init] autorelease];
        self.dataArrayController = [[NSArrayController alloc] initWithContent:nil];
        [self.dataArrayController bind:@"contentArray" toObject:self withKeyPath:@"dataArray" options:nil];

        [self loadDataArray];
    }
    return self;
}

I was able to successfully bind my array of models to the NSCollectionView which draws the views, however each individual view I want to bind the model's NSMutableArray to the NSTableView in the view. I don't think there is a way to do this programmatically because you are binding to Collection View Item.representedObject. I don't think you could do Collection View Item.representedObject.dataArrayController.arragnedObjects?

ipmcc
  • 29,581
  • 5
  • 84
  • 147
Sean Larkin
  • 6,290
  • 1
  • 28
  • 43
  • I've tried to clean up your question a little here, but it's not clear what you mean in certain cases. Views get bound to models, not the other way around, so when you say "my model is not binding to the view itself correctly" I'm not sure I know what you mean. Is this a master/detail situation? Are you trying to make an `NSCollectionView` where each item view in the collectionView then contains an `NSTableView` which is bound to some collection property on the representedObject of the `NSCollectionViewItem`? – ipmcc Jan 16 '14 at 14:38
  • For whatever it's worth, if you're interested in expedience, I would say to give up and do the bindings programmatically. In the past, I've had a hell of a time getting bindings inside collection view items working. I don't remember the specifics, but I've run into issues with things not being unarchived quite right when the collection view instantiates items from the XIB. – ipmcc Jan 16 '14 at 14:44
  • Thanks, yeah. In a simplified term, my question is better stated saying. "How do you bind a NSTableView to a models unique array controller inside a NSCollectionView". I will try and do so programatically. – Sean Larkin Jan 16 '14 at 18:51

0 Answers0