Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:20:38+00:00 2026-06-18T05:20:38+00:00

I am building a small iPhone only application (iOS SDK 6.0) and I am

  • 0

I am building a small iPhone only application (iOS SDK 6.0) and I am getting EXC_BAD_ACCESS exception in XCode.

The application has UITableView with custom UITableViewCell. I have implemented the UITableViewCell in a subclass (I call it MyCustomCell here) and added another parameter to the constructor:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellImage:(UIImage *)image;

The UIImage is added to contentView of the TableCell in the method, with following code:

imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
imageView.image = image;

[self.contentView addSubview:imageView];

This function is called within the function cellForRowAtIndexPath of course:

static NSString *CellIdentifier = @"MyCustomCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)
{
    cell = [[[MyCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier cellImage:self.cellImage] autorelease];
}

return cell;

The cellImage property of the ViewController (also the UITableViewDelegate) is declared as (it is also synthesized):

@property (nonatomic, retain) UIImage* cellImage;

The image is initialized in viewWillAppear method of ViewController with the following line:

cellImage = [UIImage imageNamed:@"my_image_resource.png"];

This code works correctly, but the EXC_BAD_ACCESS appears, when I customize the image with iOS 6.0 only function:

cellImage = [[UIImage imageNamed:@"my_image_resource.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10) resizingMode:UIImageResizingModeStretch];

Debugging helped me to locate the line that triggers the error – it is in the initWithStyle method of MyCustomCell implementation:

imageView.image = image;

I have looked through many EXC_BAD_ACCESS errors, I also read the tutorial of why does this error appear, but up to this point, I am not deallocating anything. Some object is probably released at this point, but I cannot find which one exactly and how could I fix the problem.

I have also tried creating two properties in ViewController class, one to hold the original image and the other image with insets. It does not solve the problem, however.

Why is this an error? Why it is not working with image with insets? How could I fix this problem?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:20:39+00:00Added an answer on June 18, 2026 at 5:20 am

    You’ve created a property for cellImage, but you’re setting it using the instance variable instead of the setter which has been created for you. Since you’re passing in an autoreleased object, there is a possibility that it’s been released when you try to reference it next time. Try using this below:

    [self setCellImage:[[UIImage imageNamed:@"my_image_resource.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10) resizingMode:UIImageResizingModeStretch]];
    

    Or with this:

    self.cellImage = [[UIImage imageNamed:@"my_image_resource.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10) resizingMode:UIImageResizingModeStretch];
    

    With this code, the image will be retained for you inside of the setter, and next time you try to use it, the memory will still be allocated and you shouldn’t have any issues.

    Consider also using ARC, if possible, as much of this intricate memory management stuff is handled for you. http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an app for iPhone, iPad, Android and BlackBerry. The app only has
I am building an iphone app that has a small button at the right
We are a very small mobile company (building an application for the iphone) and
I am building a small application in RoR that has a form asking for
I'm building a MonoTouch iPhone app, but have come up with a small issue.
I´m building a small application with Jquery and PHP. Jquery (index.html) adds Form Fields
Background: I'm building a small application that will be run daily, pulling data from
I'm building small one page application with rails 3.1 mongodb and backbonejs. I have
I am building small app that will only display products in various categories. And
First, I only have experience building small-medium sized websites with php so forgive me

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.