Custom View instances share variables - Not Nice - Why?
Custom View instances share variables - Not Nice - Why?
- Subject: Custom View instances share variables - Not Nice - Why?
- From: Volker Runkel <email@hidden>
- Date: Tue, 18 Oct 2005 17:58:13 +0200
Dear list,
I stumbled over the following problem:
I have a custom view (subclass of NSScrollView) which I use in my
Document (NSDocument subclass) as well as in a window owned by a
subclass of NSObject (SupportClass), which is instantiated from
within my Document. Both, Document and SupportClass each have their
own NIB file. My custom view is added to the document window, as well
as to the supporter window via Interface Builder (Custom View -> set
to my class and connected to a variable in each of the two controllers).
The CustomView adds another CustomView (ContentView for ScrollView)
which itself combines other subclasses as well.
Little schema:
CustomView (NSScrollView)
CustomView (NSView): contentView
NSImageView
CustomView (NSView): vectorData
CustomView (NSView): gridDisplay
CustomView (NSView): AxisandLabels
What happens:
First I set variables for my Documents CustomView-instance (range of
displayed data). It displays all of my data. For examination of
subdata I give values to this SupportClass-Instance which displays
only the given range. Therefore it adjusts its instance of my
CustomView.
What actually happens is, that the display range does also change in
my Documents instance of my CustomView, but not the CustomViews data !?
My CustomView implements initWithFrame in the following way (note I
add other NSView subviews):
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
numberOfTicksYAxis = 5;
minYAxis = 0;
maxYAxis = 250;
numberOfTicksXAxis = 4;
minXAxis = 0;
maxXAxis = 7.0;
zoomFactor = 1;
[self setHasHorizontalScroller:YES];
[self setAutohidesScrollers:NO];
[self setAutoresizesSubviews:YES];
[self setAutoresizingMask:NSViewWidthSizable|
NSViewHeightSizable];
[self setBackgroundColor:[NSColor clearColor]];
[self setDrawsBackground:NO];
[self setBorderType:NSGrooveBorder];
NSRect graphRect = [[self contentView] frame];
//graphRect.size.height -= 1;
scrollContentView = [[VRScrollContentView alloc]
initWithFrame:graphRect];
[[scrollContentView superview] setAutoresizesSubviews:YES];
[scrollContentView setAutoresizingMask:NSViewWidthSizable|
NSViewHeightSizable];
[self setDocumentView:scrollContentView];
YAxisView = [[VRYAxisView alloc] initWithFrame:NSMakeRect
(0,0,50,[self frame].size.height)];
[YAxisView setBoundsOrigin:NSMakePoint(0,[[self
horizontalScroller] frame].size.height)];
[YAxisView setAutoresizingMask:NSViewHeightSizable |
NSViewMaxYMargin];
[self addSubview:YAxisView];
return self;
}
return nil;
}
Volker
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden