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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:40:17+00:00 2026-05-16T08:40:17+00:00

One thing I’m concerned about is I create two ints, but don’t release them.

  • 0

One thing I’m concerned about is I create two ints, but don’t release them. Would it be better to make them NSIntegers?

-(void) flipCoin {

    int heads = [headsLabel.text intValue];
    int tails = [tailsLabel.text intValue];

    if (random() %2 ==1 )
    {
        heads++;
    }
    else {
        tails++;
    }

    headsLabel.text = [NSString stringWithFormat:@"%d", heads] ;
    tailsLabel.text = [NSString stringWithFormat:@"%d", tails];

}
  • 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-16T08:40:17+00:00Added an answer on May 16, 2026 at 8:40 am

    int is what is known as a primitive type. It is not a pointer to an Objective-C object so you cannot release it. You can’t even send a message to it.

    NSInteger is also a primitive type in the sense that it is a typedef to a primitive type (long usually). So you can’t release that either.

    What do you need to release? You need to release any object you obtained by sending new, alloc or a method containing copy. You also need to release objects to which you have sent retain. So all of the local variables in the following must be released:

    -(void) foo
    {
        NSString* aString  = [[NSString alloc] init];
        NSString* aString2 = [aString copy];
        NSString* aString3 = [someOtherString retain];
        NSString* aString4 = [@"some string" copy];
    }
    

    NB due to implementation details, you would actually get away with not releasing the aString4 but you don’t need to worry about it.

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

Sidebar

Related Questions

One thing that has bothered me about C# since its release was the lack
One thing about Oracle Apex that I just don't get is the lack of
I don't understand one thing about eGit... when I commit a project, often (usually..
There's one thing I want to do with javascript, but don't know how. In
The one thing I don't like about javascript is that there are hundreds of
One thing I don't like about writing javascript-based applications is that you have to
One thing I love about Python and PHP is the ability to make a
One thing I really miss about Java is the tool support. FindBugs, Checkstyle and
One thing I've always wondered about is how software patches work. A lot of
One thing that bugs me about IE is that when it goes to load

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.