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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:22:49+00:00 2026-05-21T00:22:49+00:00

I have a UITextView which has its text sets from a local variable. Is

  • 0

I have a UITextView which has its text sets from a local variable. Is it possible that after this:

[textView setEnabled:NO];

The retain count gets incremented by one?

EDIT:

The “problem”, if it is a problem, is in the constructor of a small view:

- (id)initWithData:(NSMutableArray *) {
  UITextView *myText;
  if ( ( self = [super init] ) ) {
    myText = [[UITextView alloc] initWithFrame:aRect];
    // retain count = 1;
    [myText setEnabled:NO]; // retain count 2
    [self addSubview:myText]; // retain count 3
    [myText release];  // retain count 2
  }
}

Now, I’ve “autoreleased” the text view, but I’m not sure if the memory is well managed (the post is related to this question).

  • 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-21T00:22:50+00:00Added an answer on May 21, 2026 at 12:22 am

    Possible? Absolutely.

    Do you care? Not a bit. Not unless you overrode setEnabled: in a subclass and you are the one making the retain call.

    If it is, it is an implementation detail in the frameworks.


    Think about retain counts as deltas, not as absolute numbers. The absolute value is meaningless. Thus:

    - (id)initWithData:(NSMutableArray *) {
      UITextView *myText;
      if ( ( self = [super init] ) ) {
        myText = [[UITextView alloc] initWithFrame:aRect]; // rc +1
        [myText setEnabled:NO]; // rc change irrelevant
        [self addSubview:myText]; // rc change irrelevant
        [myText release];  // rc -1
      }
    }
    

    So, yes, you have managed memory correctly; at the end of the scope of the myText local variable, all retains have been balanced by releases.

    When you addSubview:, whether that method retains the object or makes a copy of it is an implementation detail that isn’t relevant to memory management in this scope. Obviously, that the subview maintains a reference and retains it is necessary for its purposes, but that is an implementation detail beyond the scope of this method’s memory management!

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

Sidebar

Related Questions

I have an UITextView which takes data from XML. Now that XML node is
I'm trying to have a variable-height UITextView which changes size to accomodate its contents,
I have a UIScrollView which has a subview UITextView. When I added text to
I have a UITextView that has a lot of content. I have a button
I'm writing iPhone/iPad application. I have UITextView in which I automatically appending text. How
I have a UITextView subclass that has an NSIndexPath property that is inside a
i have a custom UIView which is presented from a UIViewController . This view
I have a textview which contains chat history obtained from a server.The chat history
I have an UITextView which is for instance 380 characters in length: NSLog(@aTextView.text lenght
In a UITextView have a text which is for readonly and dont want any

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.