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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:08:14+00:00 2026-06-11T12:08:14+00:00

I have two text fields that are for percentages to be entered in. If

  • 0

I have two text fields that are for percentages to be entered in. If i put 20 in the first field I would like the second text field to be updated to 60. And later on if I changed the second one to say 30, I would like the first updated to 70.

For ease of showing what I mean, say I have two text fields _firstPercent and _secondPercent with associated labels _firstTotal and _secondTotal:

float firstPercent = [_firstPercent.text floatValue];

float firstAmount = (firstSalePercent / 100) * firstOrigonalAmount;

_firstTotal.text = [NSString stringWithFormat:@"%1.0f",firstAmount];



float secondPercent = [_secondPercent.text floatValue];

float secondAmount = (secondSalePercent / 100) * secondOrigonalAmount;

_secondTotal.text = [NSString stringWithFormat:@"%1.0f",secondAmount];

I really don’t know how to handle this so I tried adding this below its respective code. It works for the first one, but not the second.

float percentToSecond = 100 - firstPercent;
_secondPercent.text = [NSString stringWithFormat:@"%1.0f", percentToSecond];

float percentToFirst = 100 - secondPercent;
_firstPercent.text = [NSString stringWithFormat:@"%1.0f", percentToFirst];

I have tried other solutions but don’t know what to do.

I would just like someone to lead me in the right direction.

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-11T12:08:16+00:00Added an answer on June 11, 2026 at 12:08 pm

    How about using the delegate method controlTextDidEndEditing: to see what value was entered, and then set the value for the other text field. In the following code tf1 and tf2 are the IBOutlets for the two text fields.

        -(void)controlTextDidEndEditing:(NSNotification *)obj {
        float value = [[[obj.userInfo valueForKey:@"NSFieldEditor"] string] floatValue];
        if (obj.object == self.tf1) {
            self.tf2.stringValue = [NSString stringWithFormat:@"%1.0f",100. - value];
        }else if (obj.object == self.tf2) {
            self.tf1.stringValue = [NSString stringWithFormat:@"%1.0f",100. - value];
        }
    }
    

    You’d have to do some more checking to make sure the user didn’t enter a number greater than 100 or something not a number.

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

Sidebar

Related Questions

I have two text fields that I would like to limit the number and
I have two views with navigation controller: first view, there are empty text fields
I have a method that will if check two text fields exist then retune
I have form with two text fields and onLoad=document.forms.obrazac.sifra.focus() I put cursor on the
I have two text fields in a UIAlertView. I want the second one to
I have two text fields where if i enter a date in the first
I have a movieclip called Tab that has two text-fields: named toptxt and bottomtxt.
I have two text fields, one represents a percentage and the second represents a
I have two html text input fields and two buttons. The first button saves
I have a form that has 3 types of field: (2) text fields that

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.