A have an NSView
object, and it get an message after i push in the Menü bar the Open submenü. It load exchange data from a textfile, and it should render it in a CustomView
. So the
-(IBAction)loadExchangeData:(id)sender
load the data, and store in a NSMutableArray*
, and after it should rendered it by drawRect.
But! In the drawRect
function the before loaded data disappear, the NSMutableArray*
will 0X0 again.
And part of the code:
.h:
#import <Cocoa/Cocoa.h>
@interface Chart : NSView
{
NSMutableArray * exchange;
}
- (IBAction)loadExchangeData:(id)sender;
@end
.m:
#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