Iphone UITextField值保存在哪里?
我创建了简单的gui,带有3个UITextField 添加了一个按钮,当点击提交,为测试我已经打印了3个文本值。。。我在每个字段的文本框中键入。。。我错过了什么?我是否应该在..之前将其保存到移动设备的磁盘上。。提交 IOS版本5.0测试版Iphone UITextField值保存在哪里?,iphone,ios,ios5,Iphone,Ios,Ios5,我创建了简单的gui,带有3个UITextField 添加了一个按钮,当点击提交,为测试我已经打印了3个文本值。。。我在每个字段的文本框中键入。。。我错过了什么?我是否应该在..之前将其保存到移动设备的磁盘上。。提交 IOS版本5.0测试版 #import <UIKit/UIKit.h> @interface CloudClientViewController : UIViewController { @private UITextField *usernameD
#import <UIKit/UIKit.h>
@interface CloudClientViewController : UIViewController
{
@private
UITextField *usernameData;
UITextField *passwordData;
UITextField *ngccData;
UIButton *submitButton;
}
@property (nonatomic,retain) IBOutlet UITextField *usernameData;
@property (nonatomic,retain) IBOutlet UITextField *passwordData;
@property (nonatomic,retain) IBOutlet UITextField *ngccData;
@property (nonatomic,retain) UIButton *submitButton;
-(IBAction)submitButton:(id)sender;
@end
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
/*
Allocting memory for the username password and the ngcc server
*/
usernameData = [[UITextField alloc]init];
passwordData = [[UITextField alloc]init];
ngccData = [[UITextField alloc]init];
}
-(IBAction)submitButton:(id)sender
}
现在,当gui提示时,我在UITextField字段中输入justtest作为字符串,然后单击submit,我希望看到测试字符串作为值,而不是看到null
想法
GNU gdb 6.3.50-20050815(苹果版gdb-1705)(2011年7月5日星期二07:28:08 UTC)
版权所有2004免费软件基金会。
GDB是自由软件,受GNU通用公共许可证的保护,您是
欢迎在特定条件下更改和/或分发副本。
键入“显示复制”以查看条件。
GDB绝对没有保修。有关详细信息,请键入“显示保修”。
此GDB配置为“x86_64-apple-darwin”。sharedlibrary应用所有加载规则
连接到进程10248。
2011-07-27 16:52:56.235 CloudClient[10248:207]输入到usernameData的值是:(null)
2011-07-27 16:52:56.237 CloudClient[10248:207]输入到passwordData的值为:(null)
2011-07-27 16:52:56.238 CloudClient[10248:207]输入到ngccData的值是:(null)您定义了三个IBOutlet属性,建议在加载视图时从nib文件加载文本字段
加载视图后,创建并分配支持这些属性的IVAR以指向新的文本字段。这会泄漏从nib实际加载的任何文本字段。它还为您留下了一些属性,这些属性指向尚未添加到视图中且不可见的文本字段
然后将文本输入视图中的一个文本字段(从nib加载),并想知道为什么在-viewDidLoad中创建的完全不同的文本字段不包含您输入的文本“加载视图后,创建并分配支持这些属性的IVAR以指向新的文本字段。这会泄漏从nib实际加载的任何文本字段“我不太明白。我的任务很简单,向字段输入文本,然后在日志中打印它们,我创建了新的3 textfield,然后想在日志文件中打印文本字段的文本,为了确保我能看到值,我不确定支持这些属性意味着什么…
usernameData=[[UITextField alloc]init]
与self.usernameData=[[UITextField alloc]init]不同;前者直接修改ivar,而后者实际调用该属性的setter方法。在您提供的代码中,您创建了三个UITextField
实例,并将usernameData
、passwordData
和ngccData
ivar分配给它们。但是,您还没有显示您曾经将这些文本字段添加到视图中。如果在视图中看到文本字段,它们要么与ivars引用的对象完全不同,要么忽略了代码的相关部分。
NSLog(@"The value that was entered to usernameData is: %@",usernameData.text);
NSLog(@"The value that was entered to passwordData is: %@",passwordData.text);
NSLog(@"The value that was entered to ngccData is: %@",ngccData.text);