テキストフィールドがあり、ユーザーがそこに数値を入力する必要があります。この数値を浮動小数点値に変換して、別のビューに移動する必要があります。エラーが見つかりません...Xcodeは「float valor = [[_inserir.text ] floatvalue];
」行にあると言っています。誰かが私のエラーがどこにあるかを見つけることができたら、ありがとう。
最初のビュー.h:
#import <UIKit/UIKit.h>
@interface CedulasFirstViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextField *inserir;
- (IBAction)calc:(id)sender;
@end
最初のビュー.m:(私の変数名の前の下線、xcodeはそれを単独で配置し、それを削除しても何も変更されません)
#import "CedulasFirstViewController.h"
#import "CedulasSecondViewController.h"
@interface CedulasFirstViewController ()
@end
@implementation CedulasFirstViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)calc:(id)sender {
float valor = [[_inserir.text ] floatvalue];
CedulasSecondViewController *second [[[CedulasSecondViewController alloc] init]];
second.valor = self.valor;
}
@end
2番目のビュー.h:
#import <UIKit/UIKit.h>
@interface CedulasSecondViewController : UIViewController{
}
@end
セカンドビュー.m:
#import "CedulasSecondViewController.h"
@interface CedulasSecondViewController ()
@end
@implementation CedulasSecondViewController
- (void)viewDidLoad
{
NSString *numberFromTF [[NSString alloc] initWithFormat:@"%.2f", valor];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
ありがとう
編集:
誰かが私にxcodeが変数の前にこのアンダースコアを置くように言う理由を説明できれば