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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:17:31+00:00 2026-05-29T23:17:31+00:00

As i know, If retain count of a object goes to 0 its dealloc

  • 0

As i know, If retain count of a object goes to 0 its dealloc gets called.But i am getting retain count as -1. What does it mean?

I am using following code-

    Demo *obj1 = [[Demo alloc] init];
    NSString *s = [[NSString alloc] initWithString:@"mithilesh"];
    NSString *s1 = [NSString stringWithString:s];
    [s release];
    object_setInstanceVariable(obj1, [propertyName cString], s1);
    //printing retain count 
    NSLog(@"retain count of name = %i",[obj1.name retainCount]);

Output :

   retain count of name = -1

String returned by method stringWithString: when get release ?

  • 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-29T23:17:33+00:00Added an answer on May 29, 2026 at 11:17 pm

    It means you need to stop calling -retainCount. It’s purely a debugging function, and unless you’re an Apple engineer working on system frameworks or the compiler, you probably have no business whatsoever looking at that function.

    That said, what you’re seeing here is INT_MAX being interpreted as a signed number. It sounds like you’ve got ahold of a constant string, likely @"mithilesh". Constant strings are singletons that don’t participate in -retain and -release, and a -retainCount of INT_MAX is an indication of this. But this is really just speculation, and you should stop looking at -retainCount.

    If you don’t believe me, maybe you’ll believe Bill Bumgarner when he says retainCount is useless.

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

Sidebar

Related Questions

After getting the objectEnumerator in the following code, the set1 retain count goes to
Does anybody know how can I check the retain count of an object while
I just wanted to know: will the retain count of an object be incremented
For years I've been following a great pattern called Target-Action which goes like this:
I have a basic question here. I know that dealloc will be called when
I know the basic principles about memory management (retain count, autorelease pools etc) in
I have used [anArray retainCount] to get the retain count of array..(i know this
I wonder why the retaincount of an object equal one inside its dealloc function
I don't know what is going on here but I have the following code
Know this might be rather basic, but I been trying to figure out how

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.