如何从我的模型类中调用数组NSWindowController
?在valueArray
AppDelegate 中设置为模型类ValueItem
:
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
ValueItem *vi;
ResultWindowController *rwc;
IBOutlet NSArrayController *outArrayController;
}
和
@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];
}
调用NSLog(@"vi.valueArray is:%@", vi.valueArray);
返回数组内容就好了。但是当我尝试在我的另一个中使用它时,NSWindowController
它总是返回NULL
:
@interface ResultWindowController : NSWindowController
{
ValueItem *vi;
NSNumber *resultAverage;
}
和
@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"];
}
我找不到丢失的链接?我在这里想念什么?谢谢!