we get the following error when scrolling UITableview.
EXC_BAD_ACCESS, - [Save CFString]: message sent to the freed instance
how can i find a freed instance ...? this is my noOfRowsinsection code
for(int i=0;i<size;i++)
{
NSString *CellIdentifier1;
if(universalApp==2)
{
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
CellIdentifier1 = @"CustomThumbImageTableCell_iphone";
cell = [[[CustomThumbImageTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier1] autorelease];
cell.thumbImageView = [[[CustomImageView alloc] initWithFrame:CGRectMake(4, 4, 83, 101)] autorelease];
[imgViewArray addObject:cell.thumbImageView];
[cell.thumbImageView release];
[pool release];
}
and this is my cellforRow code
enter code hereif(universalApp==2)
{
NSLog(@"iphone cell>>>>>>>>>>>>>>>>>>>>>>");
CustomThumbImageTableCell *cell = nil;
@try
{
static NSString *CellIdentifier = @"CustomThumbImageTableCell_iphone";
int currentRow = [indexPath row] ;
{
static NSString *CellIdentifier = @"CustomThumbImageTableCell_iphone";
static NSString *CellIdentifier1 = @"CustomThumbImageTableCell_iphone";
if(cell==nil)
{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[CustomThumbImageTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
cell = [[[CustomThumbImageTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier1] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSLog(@">>>>>>>>>..... %d, %d, %@", imgViewArray.count, indexPath.row, (((int)imgViewArray.count- 1) < (int)indexPath.row) ? @"YES" : @"NO");
cell.thumbImageView =[imgViewArray objectAtIndex:indexPath.row];
cell.thumbImageView.contentMode = UIViewContentModeScaleAspectFit;
[cell.contentView addSubview:cell.thumbImageView];
cell.thumbImageView.index = (int)indexPath.row;
@try
{
{
BOOL isFound = NO;
do
{
@try {
NSArray *array1 = [contentString componentsSeparatedByString:@"@@#"];
NSArray *array2 = [[array1 objectAtIndex:currentRow ] componentsSeparatedByString:@"##"];
NSString *str = [NSString stringWithFormat:@"%@", [array2 objectAtIndex:0]];
str = [str stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(104, 6, 141, 96)];
name.textAlignment = UITextAlignmentCenter;
name.font = [UIFont fontWithName:@"Arial" size:17.0];
name.numberOfLines = 3;
name.backgroundColor = [UIColor clearColor];
name.textColor = [UIColor whiteColor];
cell.catalogName = name;
[cell.catalogName setText:[NSString stringWithFormat:@"%@", str]];
[cell.contentView addSubview:cell.catalogName];
name = [[UILabel alloc] initWithFrame:CGRectMake(107, 89, 193, 21)];
name.textAlignment = UITextAlignmentCenter;
name.font = [UIFont fontWithName:@"Arial" size:13.0];
name.textColor = [UIColor whiteColor];
name.numberOfLines = 3;
name.backgroundColor = [UIColor clearColor];
name.alpha = 0.26;
cell.pageNo = name;
[cell.contentView addSubview:cell.pageNo];
if((searchId != 2 && (isLineNameSearchEnabled == 0)) || searchInCatalogFlag == 1)
[cell.pageNo setText:[NSString stringWithFormat:@"Page No: %@", [array2 objectAtIndex:(array2.count - 2)]]];
{
}
NSLog(@" thumb image = %@",[NSString stringWithFormat:@"%@%@", baseURL, [array2 objectAtIndex:1]]);
[cell.thumbImageView setImageURL:[NSString stringWithFormat:@"%@%@", baseURL, [array2 objectAtIndex:1]]];
[NSThread detachNewThreadSelector:@selector(initThread) toTarget:cell.thumbImageView withObject:nil];
[cell.thumbImageView setPageNo:((searchId == 2 || (isLineNameSearchEnabled && searchInCatalogFlag == 0)) ? 0 : (int)currentRow)];
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(264, 33, 36, 34)];
img.contentMode = UIViewContentModeScaleToFill;
[img setImage:cellArrow];
[cell.contentView addSubview:img];
[img release];
[cell.catalogName release];
[cell.thumbImageView release];
isFound = YES;
}
@catch (NSException * e) {
currentRow = [indexPath row] + 1;
}
}
while (!isFound);
}
}
source
share