I have some code which needs to access a NSArray to work. I have a NSArray which I am using with core data and will have data in it. But i am unsure how to make it access the NSArray.
I can't just simply declare it in the Header file like this: NSArray *objectArray;
because it does not know how or which NSArray to Access. How exactly would I access the NSArray I am using with core data?
Some Code To Help. Header File.
#import <Cocoa/Cocoa.h>
@interface MyOutlineView : NSOutlineView {
NSArrayController* objectArray;
}
@end
Implementation File.
#import "MyOutlineView.h"
@implementation MyOutlineView
- (void) outlineView: (NSOutlineView *) aView
willDisplayCell: (id) aCell
forTableColumn: (NSTableColumn *)aColumn
item: (id) anItem
{
id rootObj = anItem;
unsigned row = [aView rowForItem:anItem];
[aCell setDrawsBackground: YES];
while ([aView levelForRow:row] != 0) {
row --;
rootObj = [aView itemAtRow:row];
}
// The colours here are foul and ugly. Use something else, for
// God's sake!
if( [objectArray indexOfObject:rootObj] % 2 )
[aCell setBackgroundColor: [NSColor yellowColor]];
else
[aCell setBackgroundColor: [NSColor blueColor]];
}
@end