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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:50:37+00:00 2026-06-07T21:50:37+00:00

Hi i am trying to get an integer value from a NSMutableArray I called

  • 0

Hi i am trying to get an integer value from a NSMutableArray I called programStack which holds all the numbers. This method is an undo method so when I hit undo it erases the last item on the stack and returns the previous option. When i try to get the number the method undoVariable has the right value for string when it is returned but then after when it is displayed I get the wrong value. An example is having 2, 3 on the array. I erase 3 and string shows 2 in UndoVariable and then when I use self.display.text to display it displays 1.57539e-302. Could this be the pointer address? Here is the code.

- (IBAction)undoPressed {

NSString* string = self.display.text;

if(userIsInTheMiddleOfEnteringANumber){
    if([self.display.text length])
        string = [string substringToIndex:([string length]-1)];

} else {
    string = [NSString stringWithFormat:@"%g",[self.brain undoVariable]];
    NSLog(@"string is %@", string);
}

    self.display.text = string;
}

-(NSString*) undoVariable{

if(self.programStack)
[self.programStack removeLastObject];
    if(self.programStack){
        NSString* string = @"";
        string = [string stringByAppendingString: [self.programStack lastObject]];
        NSLog(@"string = %@", string);
        NSLog(@"self.display.text = %@", [self.programStack lastObject]);
        return string;
}
  • 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-07T21:50:39+00:00Added an answer on June 7, 2026 at 9:50 pm

    Your %g format says to treat the given value as a floating point number but undoVariable says it returns a NSString. If you really wanted to format it, you’d need %@. However, it’s much simpler to just use the string rather than reformatting it, as in: string = [self.brain undoVariable];.

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

Sidebar

Related Questions

im trying to get the integer value from the following xml structure (its only
Let me clarify my question. I'm trying to get an integer value from @student.rooms.last,
I'm trying to get integer or bool from database result this way: bool tblexist
I'm trying to get the integer value for b'\x00\x00\x00\x01', which should be 1 I
I'm trying to get the integer value of The number selected of the item.
I'm trying to grab avalue from a UIPicker which is populated with round numbers,
Trying to get the highest and lowest value from an array that I know
I'm trying to return an integer value from a child process. However, if I
I am trying to read an integer value from a simple text file. Row
So i am trying get 2 div-containers which both should contain centered text (Both

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.