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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:09:24+00:00 2026-06-14T10:09:24+00:00

I am crashing at runtime when i pop last element from NSMuttable array.I am

  • 0

I am crashing at runtime when i pop last element from NSMuttable array.I am getting all element fine but when i acess last element it will give error.

-(id)popOperand{
   id operandObject = [self.operandStack lastObject];
   if(operandObject) [self.operandStack removeLastObject];
   return operandObject;
}

For eg:- if in my stack i have “8”(Its NSNumber object) “+”(Its NSString object) 2(Its NSnumber Object).

NSNumber *rightOperand = [self popOperand];
NSString *operation = [self popOperand];
NSNumber *leftOperand = [self popOperand];//when i acess 8 it shows empty array other           element is getting fine;

My question is why i am not able to get last object while this function is working fine for other elememts.
EDIT : At run time when after poping 2 it show stack( 8 +) but after i poped + it show stack() empty.But The “leftOperand” is not getting value. I am not using ARC.

Please ellaborate it.
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-14T10:09:26+00:00Added an answer on June 14, 2026 at 10:09 am

    If you aren’t using ARC then you have memory management issues:

    - (id)popOperand
    {
       id operandObject = [self.operandStack lastObject];     // Still retained by operandStack
       if(operandObject) [self.operandStack removeLastObject];// Released by operandStack
       return operandObject;                                  // Could be dealloc'd any time now!
    }
    

    Try this version, which returns a retain‘d and autorelease‘d object, which conforms to the naming convention of the method:

    - (id)popOperand
    {
       id obj = nil;
       if ([self.operandStack count] > 0)
       {
           id obj = [[[self.operandStack lastObject] retain] autorelease];
           [self.operandStack removeLastObject];
       }
       return obj;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I stop Hint, a Haskell runtime interpreter library, from crashing the GHC
My iOS app is randomly crashing but I don't get any warning/error in the
I'm building my first Android program from a book. It kept crashing on an
One of our web servers is suffering from random w3wp.exe crashing and after a
Possible Duplicate: CakePHP website crashing after pagination I had a page that worked but
I am getting this runtime exception about once every thousand+ sessions on the app,
My program is crashing as a result of the runtime sending isEqualToString: to a
A service we have is occasionally crashing on a test PC. We are getting
I hav downloaded bump demo from github but when i am running this its
Crashing on sqlite3_step line? I am just deleting the row from the database. It

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.