xcode - 如何设置等于UITextField的字符串值?

标签 xcode string button crash uitextfield

我正在尝试制作它,因此您在文本字段中输入数字,然后按一个按钮。然后,一个字符串等于文本字段,然后一个标签等于该字符串。问题是当我按下按钮时它崩溃了。我究竟做错了什么?

从.h文件中:

@interface TextGameViewController : UIViewController 
 {
   IBOutlet UITextField *input;
   IBOutlet UILabel *line11;
   NSString *l11;
 }
-(IBAction)button;

从.m文件:
-(IBAction)button
 {
   [input resignFirstResponder];
   l11 = ([input.text stringValue]);
   line11.text = [[NSString alloc] initWithFormat:@"%2.f", l11];
 }

最佳答案

l11已经是一个NSString,将以下代码行更改为:

l11 = ([input.text stringValue]);


l11 = input.text;

关于xcode - 如何设置等于UITextField的字符串值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5756592/

相关文章:

xcode - 将 XCode 编译错误与部署目标 iOS 5.1 相匹配

ios - 绘制圆线iOS Swift

SwiftUI 多窗口关闭会导致崩溃

r - R中根据 "^"分割字符串

iphone - 如何自动发送短信?

php - 如何检查PHP中字符串中是否只有空格?

java - String replaceAll 不替换 i++;

javascript - Facebook 分享按钮等于 Twitter 推文按钮

swift - 将 destructiveButtonTitle 移动到 UIActionSheet 的底部

button - Godot:检测按下的鼠标是否在按钮上方