i am getting problem with this can any one help me
here is my code. This code work 1st click but when click 2 time it get error
malloc: error for object 0x4e226a4: incorrect checksum for freed object – object was probably modified after being freed.
** set a breakpoint in malloc_error_break to de**bug
- (void)updateTextViewContents {
content = [[NSMutableString alloc] init];
for (int i = 0; i <[ _scoresArray count]; i++)
{
NSMutableString *data = [_scoresArray objectAtIndex:i];
[content appendString:data];
if([content isEqualToString:UserText.text]&&[content isEqualToString:PassText.text])
{
UIAlertView *alt = [[UIAlertView alloc] initWithTitle:nil message:@"Valid User" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alt show];
[alt release];
[content release];
}
else
{
UIAlertView *alt1 = [[UIAlertView alloc] initWithTitle:nil message:@"NOT A Valid User" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alt1 show];
[alt1 release];
}
}
when i release over here it work but when i click 2nd time by entering right user name and password both alter view display at time .I think it will happen because of array get add at every cilck that’s why both alter view dispaly at time how i sovle this .
//[content release];
}
Here generate memory problem because of,
you release content NSMutableString in if condition and then append it again.
So, Don’t release in to for loop, release it out of for loop.
– (void)updateTextViewContents
{