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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:54:57+00:00 2026-06-07T20:54:57+00:00

I am having problems unable to set values taken from UItextfields from a Viewcontroller

  • 0

I am having problems unable to set values taken from UItextfields from a Viewcontroller to another class which does the calculations from those values.

@interface InitialViewController : UIViewController

@property (weak, nonatomic) IBOutlet UITextField *phValue;
@property (weak, nonatomic) IBOutlet UITextField *pco2Value;
@property (weak, nonatomic) IBOutlet UITextField *hco3Value;
@property (weak, nonatomic) IBOutlet UITextField *sodiumValue;
@property (weak, nonatomic) IBOutlet UITextField *chlorideValue;
@property (nonatomic,retain)NSDecimalNumber* ph;
@property (nonatomic,retain) NSDecimalNumber* pco2;
@property (nonatomic,retain)NSDecimalNumber* hco3;
@property (nonatomic,retain)NSDecimalNumber* sodium; 
@property (nonatomic,retain)NSDecimalNumber* chloride;

- (IBAction)analyseValues:(UIButton *)sender;

@end

in the implementation

-(void)values{
[self setPh:[[NSDecimalNumber alloc] initWithFloat:phValue.text.floatValue ]];

[self setPco2:[[NSDecimalNumber alloc] initWithFloat:pco2Value.text.floatValue]];
[self setHco3:[[NSDecimalNumber alloc ] initWithFloat:hco3Value.text.floatValue]];
[self setSodium:[[NSDecimalNumber alloc] initWithFloat:sodiumValue.text.floatValue] ];
[self setChloride:[[NSDecimalNumber alloc] initWithFloat:chlorideValue.text.floatValue] ];
}

- (void)viewDidLoad
{
[super viewDidLoad];
[self values];}

Then I have another class which takes these values ,but on running the program it runs but does assign values taken from the initialViewController.

#import <Foundation/Foundation.h>
#import "InitialViewController.h"

@interface AcidBaseCalculations : NSObject
@property (nonatomic) float ph;
@property (nonatomic) float pco2;
@property (nonatomic) float chloride;
@property (nonatomic) float sodium;
@property (nonatomic) float hco3;

@implementation AcidBaseCalculations

@synthesize ph,pco2,chloride,hco3,sodium;

-(void)calculations{
    InitialViewController *bvc = [[InitialViewController alloc] init]; 
ph = bvc.ph.floatValue ;

pco2 = bvc.pco2.floatValue;     
// these values are not being set although the program   runs successfully

hco3 = bvc.hco3.floatValue;
sodium = bvc.sodium.floatValue;
chloride = bvc.chloride.floatValue;

I want to use these new values here and perform some logical operations in this class.

  • 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-07T20:55:00+00:00Added an answer on June 7, 2026 at 8:55 pm

    You are creating a new InitialViewController with this line:

     InitialViewController *bvc = [[InitialViewController alloc] init];
    

    It is a diffrent instance than your other/original InitialViewController

    You either have to make a property

     @property(nonatomic,strong)InitialViewController myInitialVC;
    

    And set this property when you are alloc/initing your AcidBaseCalculations.
    Our you have to make property for all variables you would like to calculate and set them while alloc/initing to the

    AcidBaseCalculations

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

Sidebar

Related Questions

Im having problems with a method in a class file: public static function getPageLeft($pid)
I am having another problem with my android app which I can't find an
I'm having problems attaching to a process spawned from one of my own processes.
I am having a problem getting a result set from my Sql Server 2008
I am having a problem with Memcache being unable to set a key. Basically
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume
Having problems with the combining of two statements in a controller. Both statements work
Im having problems with displaying ONLY some elements ONLY on print page. For example
Im having problems getting at the HTML5 video tag with jQuery. Here is my

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.