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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:55:45+00:00 2026-05-23T20:55:45+00:00

Based on the following code, please advise NSString *str= [[NSString alloc] initWithString:@Hello world]; NSLog(@Length:

  • 0

Based on the following code, please advise

NSString *str= [[NSString alloc] initWithString:@"Hello world"];   

NSLog(@"Length: %lu\n", [str length]);              // 11
NSLog(@"Retain count is %lu\n", [str retainCount]); //1152921504606846975

[str release];

NSLog(@"%lu\n", [str length]);                      // 11
NSLog(@"Retain count is %lu\n", [str retainCount]); //1152921504606846975
  1. Originally I was wondering why the number was so large but then saw a a post explaining it. Let me ask this instead … Why does this number change greatly whether i use %d vs %lu. Originally, i used %d, but got a warning saying that “Conversion specified type int but the argument has the type NSUInteger (aka unsigned long). A fix was to change %d to %lu“

  2. Why doesn’t the retain count decrement? Large number still shows up unchanged, after the str is sent release

  3. Why am i still able to access the str, after it was sent 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-23T20:55:46+00:00Added an answer on May 23, 2026 at 8:55 pm

    This may be a hard answer to accept, but it’s what you should do:

    1. Don’t worry about it. (in terms of %d/%lu, those specifiers simply expect different data types, and %d (int) has a much smaller and different range from %lu (unsigned long))
    2. Don’t worry about it.
    3. Don’t do it, and especially don’t rely on it.

    It may be because you started with a constant string (@"Hello world") that the memory isn’t being deallocated when you call release, and the retainCount is large. But if you have to care about the retainCount, you’re doing it wrong.

    You are releasing the string in the right place, and that’s what matters — don’t ever try to use it later.

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

Sidebar

Related Questions

Based on an earlier post , I've written the following code. Please excuse the
I am currently running the following code based on Chapter 12.5 of the Python
My question is concerning SQL connection status, load, etc. based on the following code:
In the following code, the stack-based variable 'ex' is thrown and caught in a
I have the following code in WCF service to throw a custom fault based
Gday All, The following code displays a div based on the option that has
I have the following HTML code based on a tab menu format, i.e: <div
My project based on touch event in scrollview. im using the following code but
I want your suggestion on the following pseudo-code. Please suggest how could I improve
Please consider the following code and comments: Console.WriteLine(1 / 0); // will not compile,

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.