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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:03:17+00:00 2026-06-01T20:03:17+00:00

doing the Stanford 193 class courtesy iTunes U. I am trying to copy an

  • 0

doing the Stanford 193 class courtesy iTunes U. I am trying to copy an NSArray with strings and numbers. I want to replace certain strings with NSDictionary objects. My understanding is that this method would be faster than “replaceObjectAtIndex”

The trouble I have is that nothing seems to be getting copied into stack. The values are present in “program.” The get copied to item. But all values in stack are null. This question is not about retrieving dictionary items. NOTHING is getting copied to the NSMutable array stack regardless of whether or not there are variables to be replaced. I inserted a break point and monitored all variables (program:index, item, stack:index) as it goes through the loop.

What is particularly maddening is that at one point this function WAS working, and now it isn’t.

+(double)runProgram:(id) program
usingVariableValues:(NSDictionary *)variableValues;
{
    NSMutableArray *stack;

        for (id item in program)
        {
            if ([item isKindOfClass:[NSNumber class]]) [stack addObject:item];
            //above line because comparing numbers to strings throws exception
            else if  ( ([item isEqualToString:@"x"]) ||
                       ([item isEqualToString:@"a"]) ||
                       ([item isEqualToString:@"b"]) )  
                {
                    //if a variable is used, copy the value to program instead of the key
                    id replacement =[variableValues objectForKey:item];
                    if (!replacement) replacement = [NSNumber numberWithDouble:0.0];
                    [stack addObject:replacement];
                }
            else [stack addObject:item]; //if not a variable, just copy the item
        }
    //stack should now be a mutable copy of program, but with variables replaced

    return [self popOperandOffStack:stack];
} //runProgram
  • 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-01T20:03:18+00:00Added an answer on June 1, 2026 at 8:03 pm

    You need to alloc and init your stack variable.

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

Sidebar

Related Questions

I'm doing the HelloPoly example from the Stanford class and trying to disable the
I'm doing the SaaS Stanford class, trying to do Part 5 of this assignment
I am trying to learn Java by doing some assignments from a Stanford class
I'm trying my hand at the iPhone course from Stanford on iTunes U and
I'm doing the iTunes U Stanford CS106a course in Java and am loving it
I'm doing assignment 4 of cs193p from itunes u (fall 2011 Stanford iOS development
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing some jquery animation. I have certain divs set up with an attribute of
This particular assignment has to do with removing substrings from strings; I am trying
I'm doing the fourth assignment on the Stanford Iphone Dev Course. - (void)applicationDidFinishLaunching:(UIApplication *)application

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.