Reputation: 3805
In my applications i need to display and hide based upon some user action, i have done following
In interface definition, have added views like that
@interface MyWnd : NSWindowController {
MyCustomView1 *pCtmView1;
MyCustomView2 *pCtmView2;
}
In source file have following relevant methods
-(void)CreateSubViews{
NSRect subViewRect = [self GetSubViewRect];
pCtmView1 = [[ MyCustomView1 alloc]initWithFrame:subViewRect]
pCtmView2 = [[ MyCustomView2 alloc]initWithFrame:subViewRect]
initially both view will be hidden
[pCtmView1 setHidden:TRUE];
[pCtmView2 setHidden:TRUE];
[[self window] view addSubView:pCtmView1];
[[self window] view addSubView:pCtmView2];
}
-(void)ShowSubView:(int)viewId{
if(viewId == 0 ){
[pCtmView1 setHidden:FALSE];
[pCtmView1 setNeedDisplay:YES];
}
if(viewId == 1 ){
[pCtmView2 setHidden:FALSE];
[pCtmView2 setNeedDisplay:YES];
}
}
In Init Application i am Calling ShowSubView:0 and its working fine,
but depend upon the some user action, i will call ShowSubView:1 and nothing is displayed &
EXEC_BAD_ACCESS i could see in the gdb
Please guide me, do i need to do something more to display the view
Thanks
Upvotes: 0
Views: 4289
Reputation: 96323
When your app crashes, look in the Debugger window—it'll tell you what your app was doing when it crashed.
You'll probably want to stop the debugger and re-run your app under Instruments's Zombies instrument. When the crash is because you messaged a dead object (which is the cause probably 80% of the time in Cocoa), the Zombies instrument will tell you what object that was and what killed it.
Upvotes: 2