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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:30:12+00:00 2026-06-03T14:30:12+00:00

What I did is int main(int argc, char *argv[]){ NSString *str = [[NSString alloc]

  • 0

What I did is

int main(int argc, char *argv[]){
    NSString *str = [[NSString alloc] init];
    str = @"a a a a a a a a a ";
    [str release];
    NSLog(@"string is %@",str);
    return 0; 
}

I think string will be nil because we release it before printing it. However, it is not. Therefore, my consumption is wrong.

Can anybody advice me and correct me. Any comments are welcomed. 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-06-03T14:30:13+00:00Added an answer on June 3, 2026 at 2:30 pm
    NSString *str = [[NSString alloc] init];
    

    This declares a variable that is a pointer to an instance of NSString, allocates memory for an instance of NSString, initialises that memory, then assigns a pointer to that memory to the variable you declared.

    str = @"a a a a a a a a a ";
    

    This creates an NSString constant and assigns a pointer to it to the variable that you declared. As you no longer have a reference to the original NSString object you created, you have leaked the memory you allocated for it.

    [str release];
    

    This declares that this code no longer wishes to be an owner of the memory allocated to str. As you created it with a string literal, this object will always exist in your program, and releasing it does nothing.

    I think string will be nil because we release it before printing it.

    Releasing an object does not ever set it to nil.

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

Sidebar

Related Questions

Below is my code #import <stdio.h> #import <string.h> int main(int argc, const char *argv[])
I have the following program: int main(int argc, char *argv[]) { int a, b;
#include <stdio.h> #include <stdlib.h> int main ( int argc, char *argv[] ) { //sets
#include <iostream> #include <fstream> #include <string> using namespace std; int main (int argc, char*
Did you used Dynamic websites before? you see its a good way for making
Did some searches here & on the 'net and haven't found a good answer
Did you ever have the following situation: you need to store information, but a
Did anyone tried to customize the window in which the quicktime is playing video?
Did about 30 minutes worth of searching, found lots of relevant info, but none
Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;

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.