0
ViewController에서 가져온 값을 UItextfields에서 가져온 값을 해당 값의 계산을 수행하는 다른 클래스로 설정할 수없는 문제가 있습니다. 구현값을 UIViewController에서 계산할 다른 클래스로 가져온 값을 설정할 수 없습니다.
-(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];}
에서
@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
그때 나는이 값을 사용합니다 다른 클래스를 가지고 있지만, 프로그램을 실행에 그것을 실행하지만 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;
여기서 새 값을 사용하고이 클래스에서 일부 논리 연산을 수행하고 싶습니다.