| Computers Forum Index » Computer Languages (Objective-C) » Not sure how virtual function calls are being handled... |
|
Page 1 of 1 |
|
| Author |
Message |
| charstarstar3 at (no spam) gmail.com... |
Posted: Wed Jun 24, 2009 12:33 am |
|
|
|
Guest
|
Hi ,
I'm doing some Iphone development using opengl I'm trying to subclass
EAGLView so I did the following:
#import <Foundation/Foundation.h>
#import "EAGLView.h"
#import "ParticleSystem.h"
at (no spam) interface GLBase : EAGLView {
ParticleSystem * particles;
}
at (no spam) end
------
..m file:
#import "GLBase.h"
at (no spam) implementation GLBase
- (void) setupScene
{
/*** some code**/
}
- (void) drawScene:(float) time
{
[particles render:time];
}
at (no spam) end
i then changed EAGLView initWithCoder method as follows:
//The GL view is stored in the nib file. When it's unarchived it's
sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
[self setupScene];
however when I run the debugger it never calls setupScene for the
GLBase class (rather it is still calling the setupScene in the
EAGLView class) ...
I have the following changes to my main application delegate:
at (no spam) class GLBase;
at (no spam) interface testAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
GLBase *glView;
}
at (no spam) property (nonatomic, retain) IBOutlet UIWindow *window;
at (no spam) property (nonatomic, retain) IBOutlet GLBase *glView;
at (no spam) end
Can anyone help? |
|
|
| Back to top |
|
|
|
| Stefan Arentz... |
Posted: Wed Jun 24, 2009 5:18 am |
|
|
|
Guest
|
"charstarstar3 at (no spam) gmail.com" <charstarstar3 at (no spam) gmail.com> writes:
....
Quote: i then changed EAGLView initWithCoder method as follows:
//The GL view is stored in the nib file. When it's unarchived it's
sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
[self setupScene];
however when I run the debugger it never calls setupScene for the
GLBase class (rather it is still calling the setupScene in the
EAGLView class) ...
You will need to call the super's init method yourself:
- (id) initWithCoder: (NSCoder*) coder
{
if ((self = [super initWithCoder: coder]) != nil) {
[self setupScene];
}
return self;
}
Please note that this will probably create a 500 message thread
because some people will religiously state that the above way to call
the super's init method is completely wrong. Ignore them.
S. |
|
|
| Back to top |
|
|
|
| charstarstar3 at (no spam) gmail.com... |
Posted: Wed Jun 24, 2009 5:34 pm |
|
|
|
Guest
|
On Jun 23, 6:18 pm, Stefan Arentz <ste... at (no spam) keizer.soze.com> wrote:
Quote: "charstarst... at (no spam) gmail.com" <charstarst... at (no spam) gmail.com> writes:
...
i then changed EAGLView initWithCoder method as follows:
//The GL view is stored in the nib file. When it's unarchived it's
sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
[self setupScene];
however when I run the debugger it never calls setupScene for the
GLBase class (rather it is still calling the setupScene in the
EAGLView class) ...
You will need to call the super's init method yourself:
- (id) initWithCoder: (NSCoder*) coder
{
if ((self = [super initWithCoder: coder]) != nil) {
[self setupScene];
}
return self;
}
Please note that this will probably create a 500 message thread
because some people will religiously state that the above way to call
the super's init method is completely wrong. Ignore them.
S.
Thanks -- but it is already calling the super class method -- it never
calls the subclass version of setupScene
for instance I added a blank method to EAGLView called "drawScene"
which is always called even though I re-implemented the method in
GLBase |
|
|
| Back to top |
|
|
|
| charstarstar3 at (no spam) gmail.com... |
Posted: Wed Jun 24, 2009 5:54 pm |
|
|
|
Guest
|
I figured out the problem -- my MainWindow.xib file was still
constructing a EAGLView so GLBase wasn't ever being constructed
On Jun 24, 10:34 am, "charstarst... at (no spam) gmail.com"
<charstarst... at (no spam) gmail.com> wrote:
Quote: On Jun 23, 6:18 pm, Stefan Arentz <ste... at (no spam) keizer.soze.com> wrote:
"charstarst... at (no spam) gmail.com" <charstarst... at (no spam) gmail.com> writes:
...
i then changed EAGLView initWithCoder method as follows:
//The GL view is stored in the nib file. When it's unarchived it's
sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
[self setupScene];
however when I run the debugger it never calls setupScene for the
GLBase class (rather it is still calling the setupScene in the
EAGLView class) ...
You will need to call the super's init method yourself:
- (id) initWithCoder: (NSCoder*) coder
{
if ((self = [super initWithCoder: coder]) != nil) {
[self setupScene];
}
return self;
}
Please note that this will probably create a 500 message thread
because some people will religiously state that the above way to call
the super's init method is completely wrong. Ignore them.
S.
Thanks -- but it is already calling the super class method -- it never
calls the subclass version of setupScene
for instance I added a blank method to EAGLView called "drawScene"
which is always called even though I re-implemented the method in
GLBase |
|
|
| Back to top |
|
|
|
|