我一直在尝试解决此问题一段时间,但无法弄清楚它发生的原因。它似乎只在“存档”应用程序并在设备上运行时发生,而不是在调试应用程序时发生。
我有两节课:
@interface AppController : NSObject <UIApplicationDelegate>
{
EAGLView * glView; // A view for OpenGL ES rendering
}
@interface EAGLView : UIView
{
@public
GLuint framebuffer;
}
- (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)fformat depthFormat:(GLuint)depth stencilFormat:(GLuint)stencil preserveBackbuffer:(bool)retained scale:(float)fscale msaaMaxSamples:(GLuint)maxSamples;
我正在初始化一个对象:
glView = [ EAGLView alloc ];
glView = [ glView initWithFrame:rect pixelFormat:strColourFormat depthFormat:iDepthFormat stencilFormat:iStencilFormat preserveBackbuffer:NO scale:scale msaaMaxSamples:iMSAA ];
NSLog(@"%s:%d &glView %p\n", __FILE__, __LINE__, glView );
NSLog(@"%s:%d &glView->framebuffer %p\n", __FILE__, __LINE__, &glView->framebuffer );
initWithFrame 看起来像:
- (id) initWithFrame:(CGRect)frame
/* ... */
{
if( ( self = [super initWithFrame:frame] ) )
{
/* ... */
}
NSLog(@"%s:%d &self %p\n", __FILE__, __LINE__, self );
NSLog(@"%s:%d &framebuffer %p\n", __FILE__, __LINE__, &framebuffer );
return self;
}
日志显示:
EAGLView.mm:399 self 0x134503e90
EAGLView.mm:401 &framebuffer 0x134503f68
AppController.mm:277 glView 0x134503e90
AppController.mm:281 &glView->framebuffer 0x134503f10
当包含它的对象没有改变时,这个成员变量的地址怎么会改变呢?