How to call array from the model-class in my NSWindowController? The valueArray is set in AppDelegate, to the model-class ValueItem:
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
ValueItem *vi;
ResultWindowController *rwc;
IBOutlet NSArrayController *outArrayController;
}
and
@implementation AppDelegate
....
- (IBAction)pushOk:(NSButton *)sender
{
self->vi = [[ValueItem alloc]init];
[vi setValueArray:[outArrayController arrangedObjects]];
NSLog(@"vi.valueArray is:%@", vi.valueArray);
if (rwc)
{
[rwc close];
}
rwc = [[ResultWindowController alloc] init];
[rwc setShouldCascadeWindows:NO];
[rwc showWindow:self];
}
Calling NSLog(@"vi.valueArray is:%@", vi.valueArray); return the arrays content just fine. But when I try to use it in my other NSWindowController it return always NULL:
@interface ResultWindowController : NSWindowController
{
ValueItem *vi;
NSNumber *resultAverage;
}
and
@implementation ResultWindowController
@synthesize resultAverage;
...
- (IBAction)pushChange:(NSButton *)sender
{
[self calculateAverage];
[_outputLabel setDoubleValue:[resultAverage doubleValue]];
NSLog(@"resultAverage is:%@", resultAverage);
NSLog(@"vi.valueArray is:%@", vi.valueArray);
}
-(void)calculateAverage
{
resultAverage = [vi.valueArray valueForKeyPath:@"@avg.nomValue"];
}
I can't find the missing link? What do I miss here? Thanks!