EXC_BAD_ACCESS issue
<p>I am showing employee records as rows in a screen 
I want the option to remove these and show a new set of records when I click a button </p>

<p>The structure / organization of my code is as follows :
In My controller .h </p>

<pre><code>NSMutableArray *employeeScrollViewArray;
IBOutlet UIScrollView *employeeScrollViewItems;
</code></pre>

<ul>
<li><p>Here I have a UIScrollView  - employeeScrollViewItems - which is populated with rows shown on the UI</p></li>
<li><p>I also store these rows in an array - employeeScrollViewArray</p></li>
</ul>

<p>Initialization and release of objects in MyController.m file is as shown:
In the method</p>

<pre><code>- (void)viewDidLoad {
employeeScrollViewArray=[[NSMutableArray alloc]init];
</code></pre>

<p>I am releasing this mutable array in the method :</p>

<pre><code>- (void)dealloc {
[employeeScrollViewArray release];
</code></pre>

<p>when the  view loads I populate this array with objects from a user Defined class in a method :
EmployeeDetail.m file </p>

<pre><code>EmployeeDetail *empDetail=[[EmployeeDetail alloc]init];
empDetail.delegate=self;
 [[NSBundle mainBundle] loadNibNamed:@"EmployeeDetail" owner:empDetail options:nil];
[self.employeeScrollViewItems addSubview:empDetail.view]; 
[employeeScrollViewArray addObject:empDetail];
</code></pre>

<p>The details of the "h" file foe EmployeeDetail.h is :</p>

<pre><code>@interface EmployeeDetail : UIViewController


UIView *view;
</code></pre>

<p>This is the "view" that is populated with data and shown on the screen </p>

<p>I now want to cleanup /remove these objects 
So I tried things like this : ( which is then causing the exception ) </p>

<pre><code>int yyy = [employeeScrollViewArray count];
 for(int xxx=yyy-1;xxx&gt;=0;xxx--){
    if ([[[employeeScrollViewItems subviews]objectAtIndex:xxx ]isKindOfClass:[UIView class]]) {
     [[[employeeScrollViewItems subviews ]objectAtIndex:xxx] removeFromSuperview];
    }
    [employeeScrollViewArray removeObjectAtIndex:xxx];
   }//for
</code></pre>

<p>This is the only way that I am able to remove these objects 
If I try to remove them separately I get this error </p>

<p>However even after I remove the items and code passes - it still throws this error 
If I remove this code then things work - but then I cannot remove these objects </p>

<p>Please help !</p>
