• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Custom View instances share variables - Not Nice - Why?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Custom View problem - Example code
      • From: Volker Runkel <email@hidden>
    • Addition to: Custom View instances share variables - Not Nice - Why?
      • From: Volker Runkel <email@hidden>
  • Prev by Date: Plus/minus example?
  • Next by Date: Re: Determining OS version
  • Previous by thread: Plus/minus example?
  • Next by thread: Addition to: Custom View instances share variables - Not Nice - Why?
  • Index(es):
    • Date
    • Thread