Thread 1: EXC_BAD_ACCESS ( code=2,address=0x0) { Inside switch case}
===

I have created a navigation controller with two viewcontrollers in storboard. The first viewcontroller has a start button from where I segued to second viewcontroller. Inside the secondviewcontroller I have placed a segment control which has three segments with titles: Man , Truck , Movie.

 

Declared and defined setActiveModel method inside the implementation file of second viewcontroller. This method has switch case for three segments in segmentcontrol.

 

and finally inside the IBaction for segment control called this setActivemethod.



    - (void) setActiveModel: (int) modelIndex
    {
        switch ( modelIndex )
        {
            case 0:
            {
                m_truckModel->setVisible(false); **---->>[ I get BAD_ACCESS error in this line which steps over in the debugger to viewdidload method to the line where I initialize setActiveModel to integer 0 ]    <<-----**
                m_metaioMan->setVisible(true);
               
                // stop the movie
                m_moviePlane->stopMovieTexture();
                m_moviePlane->setVisible(false);
                m_moviePlaneButton->setVisible(false);
            }
                break;
               
               
            case 1:
                m_truckModel->setVisible(true);
                m_metaioMan->setVisible(false);           
               
                // stop the movie
                m_moviePlane->stopMovieTexture();
                m_moviePlane->setVisible(false);
                m_moviePlaneButton->setVisible(false);
                break;
               
               
            case 2:
                m_truckModel->setVisible(false);
                m_metaioMan->setVisible(false);
               
                m_moviePlane->setVisible(false);
                m_moviePlaneButton->setVisible(true);
                break;
        }
       
    }
    
     
    
    - (IBAction)onSegmentControlChanged:(UISegmentedControl*)sender
    {
        [self setActiveModel:sender.selectedSegmentIndex];
    }

 

