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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:18:04+00:00 2026-06-17T07:18:04+00:00

I am creating a very simple calculator. To save the first user inputed float

  • 0

I am creating a very simple calculator. To save the first user inputed float, i save it as a string in the addition action as to save it when they click on the addition button. Then later I call upon it again to add it to the second user inputed float. However when i call upon it again it gives the error: Use of undefined identifier num1. The same thing happens with the operation integer. Here is the relevant code:

- (IBAction)addition {

    NSString *number1 = total.text;
      float  num1 = [number1 floatValue];
    int operation = 1;
    total.text = @"";

}

- (IBAction)equal {

    NSString *number2 = total.text;
    float num2 = [number2 floatValue];

    if (operation == 1) {
        int num3 = num1 + num2;


    NSString *znumber1 = [NSString stringWithFormat:@"%f", num1];
}
  • 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-17T07:18:05+00:00Added an answer on June 17, 2026 at 7:18 am

    You need to declare num1 as an “instance variable” so it’s accessible by both functions (usually declared within your @interface block).

    The way you’re declaring it only allows for the code within that function’s scope to access it.

    I would reccomend reading up on variable scope before continuing.

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

Sidebar

Related Questions

I am creating a very simple forum as my first MVC project. My database
Hi guys I'm creating a very simple socket server that lets its clients save
I am creating a very simple EF4 code first project with one entity. public
creating a very simple scheduling app I am asking the user to tell me
I'm creating an app on android in java, very simple, which has a button
I'm creating a very simple timeshare application using Sinatra and Datamapper. Every user in
I am creating a very simple to-do list application. Each user should have an
I am currently creating a very simple bank account program: The user enters the
I am sort of stuck while creating something very simple - a new user.
I'm creating a very simple django upload application but I want to make 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.