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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:16:34+00:00 2026-05-16T02:16:34+00:00

I need a value to be calculated in it’s getter method if it isn’t

  • 0

I need a value to be calculated in it’s getter method if it isn’t set already. I prefer to use a nullable int construction, so I don’t need another bool to check if it’s already been calculated.

My first hunch was to go for a NSInteger *. I can check if it’s NULL and otherwise set a value to it. But I don’t know if it’s possible, since I can’t really get a value assigned to it.

    if (!value)
    {
        value = [self calcValue]; 
    }
    return value;

This leads to Assignment makes pointer from integer without cast and Return makes integer from pointer without a cast.

How would I assign a int to a NSInteger *?
How would I cast a NSInteger * to a int?

Or: what is a better solution to this problem?

  • 1 1 Answer
  • 1 View
  • 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-16T02:16:35+00:00Added an answer on May 16, 2026 at 2:16 am

    An NSInteger is actually an int. You’re looking for NSNumber, which lets you treat numbers as objects.

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

Sidebar

Related Questions

I'm creating a set of enum values, but I need each enum value to
I need to get the value of the 'test' attribute in the xsl:when tag,
I need to convert a value which is in a DateTime variable into a
I need to round a value up to the nearest multiple of 2.5. For
I need to substitute the value of a string into my regular expression in
I need to read the value of a property from a file in an
I need to get a value from a textbox inside a FooterTemplate in the
I need to store a list of key value pairs of (integer, boolean) in
I need a way to update the month value on a dateTime field in
I need a way to do key-value lookups across (potentially) hundreds of GB of

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.