Jeff Decker wrote:

It turns out that the instance of my PolygonShape class in my PolygonView class does not have any information attached to it.


Did you ever do anything to attach information to it?
Did you assign the variable a value?


I am not sure how to connect the PolygonShape instance, which is shared by PolygonShape and Controller, to PolygonView. I declared an instance of PolygonShape *myPolygon in the interface of PolygonView.h.


Post your code for PolygonView.h and explain what you mean by "shared".

Declaring a variable is not the same as assigning that variable a value.

Declaring a variable is like telling someone "Here's an empy box. Call it 'shovel'. You will put a shovel in it for digging in the garden." If you don't give them any shovels, or they don't have an independent source of shovels, the box remains empty. If you then tell them "Take the contents of the 'shovel' box and use it to dig a hole in the garden" I don't think a hole will get dug.


How do I get PolygonView to "know" about the PolygonShape instance that all the other classes know about?


Be specific. If "the PolygonShape instance that all the other classes know about" means "the variable myPolygon", then please say "the variable myPolygon". Otherwise we might wonder if you're referring to some other PolygonShape instance, and without seeing all your code, we have no idea what you're talking about.

The code apparently "knows" about the variable named myPolygon, or it wouldn't compile.

If myPolygon is null, it's probably because no value was ever assigned to it. That is, nowhere have you executed a statement like:
  myPolygon = someExpressionYieldingAPolygon;

If you have executed such a statement before drawRect: is called, post the code for it and make sure it's actually being executed at the proper time.

Also make sure something else isn't coming along after the assignment and before drawRect:, and assigning null.

  -- GG

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to