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

  • SEARCH
  • Home
  • 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 7721573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:57:31+00:00 2026-06-01T03:57:31+00:00

In my iPad App, I have one custom class inherited from UIButton. I am

  • 0

In my iPad App,

I have one custom class inherited from UIButton.

I am adding the buttons on my main view dynamically using for loop.

This button has also has label.

My problem is when to release the Custom Class’s Objects.

for(NSMutableDictionary *dict  in Categories)
{

Category *category=[[Category alloc] initWithName:[dict valueForKey:@"category_name"]  identity:[[dict valueForKey:@"category_id"] intValue] imageName:nil];

category.lblimagesCount=[[UILabel alloc] initWithFrame:CGRectMake(category.frame.size.width-31,   category.frame.origin.y-42, 26, 26)];

[category addSubview:category.lblimagesCount];

[self.viewHeader addSubview:category];

[category release];
category=nil;

}

How to avoid memory leaks.
Especially for
1. labels
2. Category class.

Where to write release ?

i. Category class(UIButton) has its dealloc method but it is never called.

ii. As I am releasing it immediately after adding it to the subview , Will it affect my button click.

iii. When should I release the labels.

Very confused about the memory management.

  • 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-01T03:57:33+00:00Added an answer on June 1, 2026 at 3:57 am

    I’ll answer your questions:

    i. Category class(UIButton) has its dealloc method but it is never called.
    Because its not totally released, see question ii.

    ii. As I am releasing it immediately after adding it to the subview , Will it affect my button click.
    No, because your subview is now the owner of the button, when you add it to the subview, both you and the subview are owners, when you release, the button now is owned by the subView.

    iii. When should I release the labels.
    As soon as you add then to the subview, for the same reason as the question ii.

    I’ll be happy to clarify if you dont understand it.

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

Sidebar

Related Questions

In a split-view-based iPad app I'm using a custom background image in my navigation
I have a universal iOS app with a custom view that has three buttons,
I have an iPad app with several segmented controls, including one view with two
If I'm creating a universal iPhone/iPad app, I have two XIBs. One main XIB
I have a magazine Ipad app that dynamically adds/removes webviews from a scrollview to
In my iPad app I have two textfields. One displays the normal, default textfield
I have this iPad app using Storyboard. There are some file that are marked
I have recently built an iPad app using PhoneGap. Currently it saves the last
I have an iPad app and I'm trying to generate a PDF from a
I have an Ipad app what has multiple OpenGL tile images, couple buttons in

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.