• 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
Multiple instantiations of variables & class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple instantiations of variables & class


  • Subject: Multiple instantiations of variables & class
  • From: Chad Armstrong <email@hidden>
  • Date: Sat, 23 Mar 2002 23:36:19 -0700

Below is a description of my problem I'm having with mysterious difficulties with variables.
I put a printf statement in my - (id)initWithFrame:(NSRect)frame function in my EGView.h file (which is responsible for drawing to the custom NSView), and the printf function revealed that the function was being called 3 times! One time it seems to be called from the MainNib.nib in the Interface Builder since I added the EGView class, and another one is when I declare an instance of the class in my main controller class. However, there seems to be one more mysterious and hidden call to this function...any ideas? Or should I change -(id) initWithFrame to just an -(id)init function?

Best regards,

Chad Armstrong
email@hidden


-----------------------------------------------------------------------

My second problem involves the changing (or not changing) of variables
in a class. In my EGView class which deals with the information drawn
to a custom NSView, I have one function which is called by my controller
class. When the EGView variables are incremented like so:

myVar += 1.0;

I then print out the variable, and it starts out at 0.0, BUT when myVar
is initialized it starts out at a different value other than 0.0. So
when I print out the value of myVar from the method which is
incrementing, it shows it is being incremented. However, when I look at
the value from the drawRect function, it sees the original initialized
value. If I change the myVar value in the drawRect function, then it
increments fine, but this does not affect the 'other' myVar. What is
going on here? Things which should seem fairly straightforward are
becoming very irritating.

On one bright note, I did figure out how to get 'external' variables of
the drawRect function to work properly. I needed to call a self =
[super initWithFrame:frame]; in my initialization method for EGView.

Anyway, these seem to be some very odd and irritating errors, and I hope
someone can figure out how they might be corrected, if possible.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Multiple instantiations of variables & class
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: Rép : Cocoa's Popularity
  • Next by Date: Precision
  • Previous by thread: Re: Apple and Developers (was lots of different subjects)
  • Next by thread: Re: Multiple instantiations of variables & class
  • Index(es):
    • Date
    • Thread