0
在我的应用程序中,我接受一个UITextField值并对其进行修剪并分配给一个字符串在Appdelegate中声明的变量。它赋值给一个appdelegate变量并且工作正常,有时它不会赋值给appdelegate变量(这个值在另一个视图中使用,所以在appdelegate中声明)。 Plz帮助...字符串值不能分配给iPhone中的字符串变量?
NSString *txtTemp=[NSString stringWithFormat:@"%@",[txtName.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
txtName.text=txtTemp;
[self appDelegate].customSearchQuery=[NSString stringWithFormat:@"%@",txtTemp];
NSLog(@"--appDelegate.customSearchQuery =%@",appDelegate.customSearchQuery);
确保`appDelegate`变量被初始化('的appDelegate = [[UIApplication的sharedApplication]代表]`)你在做上述操作之前。 – EmptyStack 2011-02-01 08:53:00