The nested class will only be able to reference static members in the parent. If you want to access instance members, you need to get a reference to the instance. The simplest way to do this is to add it as a parameter to the constructor of MyPinAnnotationView like so.
The nested class will only be able to reference static members in the parent. If you want to access instance members, you need to get a reference to the instance. The simplest way to do this is to add it as a parameter to the constructor of MyPinAnnotationView like so: class MyPinAnnotationView { private GamePlay gamePlay; public MyPinAnnotationView(GamePlay gamePlay) { this.
GamePlay = gamePlay; } public void TouchesBegan() { this.gamePlay.CheckAnswer(); } } When you instantiate MyPinAnnotationView from GamePlay, just do this: MyPinAnnotation annotation = new MyPinAnnotation(this).
If the methods you want to access are not static, then you will need a reference to the parent object (I commonly pass the parent object reference in as a constructor parameter) in order to access its methods. After all, your child class needs to know which instance of the parent class it is related to.
Thanks. Makes sense. – Bryan Nov 9 '09 at 21:52.
The easy/quick way would be to keep a reference to the parent class in the child object, make CheckAnswer() public, then it's easy to call the method whenever needed... but you may want to go back and review the design to make sure this is appropriate.
Nested classes should only be utilized by the parent class (see this post). They shouldn't be publicly visible to other classes unless there is a really good reason. Which there isn't.
I would suggest refactoring this. Try moving all the API for GamePlay into the GamePlay class. In other words, TouchesBegan() should be called on the GamePlay class, which then calls into the MyPinAnnotations class.No one else should know about MyPinAnnotations class - if they need to, then it is indicative of a design failure.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.