A 有一个NSView
对象,当我在菜单栏中按下打开子菜单后,它会收到一条消息。它从文本文件加载交换数据,并应将其呈现为CustomView
. 所以
-(IBAction)loadExchangeData:(id)sender
加载数据,并存储在 aNSMutableArray*
中,之后它应该由 drawRect 呈现。
但!函数中之前加载的drawRect
数据消失,NSMutableArray*
会再次变为0X0。
以及部分代码:
。H:
#import <Cocoa/Cocoa.h>
@interface Chart : NSView
{
NSMutableArray * exchange;
}
- (IBAction)loadExchangeData:(id)sender;
@end
米:
#import "Chart.h"
@implementation Chart
- (IBAction)loadExchangeData:(id)sender {
...
exchange = [NSMutableArray array];
[exchange addObject:...];
...
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
...
id sth = [exchange objectAtIndex:i];
...
}
@end