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 731531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:02:14+00:00 2026-05-14T07:02:14+00:00

i have this in the superview: mySubView = [[MySubView alloc] init]; [self addSubview:mySubView]; [mySubView

  • 0

i have this in the superview:

mySubView = [[MySubView alloc] init];
[self addSubview:mySubView];
[mySubView release];

then at some point later, in the sub view, this:

[self removeFromSuperview];

when i debug it, i notice that the dealloc for the subview is never called, even though i’m fairly sure the reference count should be 0. any ideas why this might be? thanks.

  • 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-05-14T07:02:15+00:00Added an answer on May 14, 2026 at 7:02 am

    Yes, When you send removeFromSuperview, subsequently release message sent. And each call of release decrease retain count. And in case:

    MySubView * mySubView = [[MySubView alloc] init];
    [window addSubview:mySubView];
    [mySubView release];
    [mySubView removeFromSuperview];
    

    the result will be as you expect: after removeFromSuperview mySubView’s retain count became 0, and dealloc will be called.

    but in your example there is more code behind “then at some point later” and some other object (and it is not superview) retains mySubView. You can for example log retainCount value to see where your view retained/relesed.

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

Sidebar

Related Questions

Hey all... I have a view controller (A) which on some action, alloc init's
Writing the code below without dot notation, do I have this right? from: if(self.yellowViewController.view.superview
Have this self-made slider: http://jsfiddle.net/wyc3P/4/ What it does: takes min and max values in
I have created a scrollview, and some button are placed on this scrollview. And
I have a storyboard with a UIViewController. Inside this view, I've placed a custom
have a little problem with this code: UITableViewCell *cell = (UITableViewCell *)[[button superview] superview];
I have a view controller with this code on the ViewDidLoad... UIImage *imageU =
So, in Interface Builder I have a view within the superview that contains two
I have this in my table view controller, and i want to pass the
I have a couple of UIViews in the same superview . One view which

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.