0

i am having a array called temparray and have 2 seperate arrays .i have two buttons ,when i tap the first button it lodes the first array to the temp array,and when i tap the second button it lods the second array to the temparray. my code is

-(IBAction)_clickbtnlanselmlayalm:(id)sender
{
    [tempArray removeAllObjects];
    [tempArray addObjectsFromArray:delegate.allSelectedVerseMalayalam];    
    [self.tab reloadData];
}
-(IBAction)_clickbtnlanselhindi:(id)sender
{
    [tempArray removeAllObjects];
    [tempArray addObjectsFromArray:delegate.allSelectedVerseHindi];
    [self.tab reloadData];
}

allSelectedVerseMalayalam and allSelectedVerseHindi are two arrays which lodes from application delegate.after tap the first button it losds the first array and show it in tableview,but when i tap the scrond button i receve a warning in [tempArray removeAllObjects]; programe receiving signal sigrabat.and it crashes the app.then i put [tempArray removeAllObjects]; again it crashes. whats the problem in my code.please help me to find the eroor. thanks in advance.

2
  • keep a breakpoint at [tempArray removeAllObjects]; and check if it is nil. Commented Mar 28, 2012 at 6:49
  • can't understand you because you don't know English Commented Mar 28, 2012 at 6:54

3 Answers 3

3

Are you sure your tempArray is properly initialized and is in fact a NSMutableArray (NSArrays are immutable and don't support addObject:/removeAllObjects/etc)?

Sign up to request clarification or add additional context in comments.

1 Comment

Hm. Try adding a [tempArray count] check before the removeAllObjects in both functions.
0

The problem is with your tempArray object (retains & releases). Is tempArray a property ? How did you declared it ?

Comments

0

did you initialize tempArray before you removeAllObjects method? check this is null or not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.