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 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 am in need of a hash value calculated on an IP address and
i need Enumarable value from below class but give error public static Enumerable LoadDataByName(string
MSDN docs say that only value types need boxing, but this does not apply
I have an app where I need a BOOL value to persist across launches.
The xmlns attribute in the following code stops me getting the value I need.
When creating a new entity object that has a foreign key value I need
I'm designing a Java based web-app and I need a key-value store. Berkeley DB
For example i have this xml. I need to get value of parameter val
I need to get the value of the 'test' attribute in the xsl:when tag,

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.