2010-08-24 56 views
0

我想从繁重的用户即名称和位置处的两个值,然后想将它们连接为一个字符串,以产生输出字符串如何连接两个的UITextField值成一个字符串在iphone

IBOutlet UITextField *txtName; 
IBOutlet UITextField *txtLoc; 

要连接它们以产生下面的字符串。

学生姓名是txtName的和他是从txtLoc

基本上这就是我的完整代码。

NSString *message = [NSString stringWithFormat:@"Student Name is %@ from %@ phone Number is%@ and he want to say%", txtName.text, txtLoc.text,txtPho.text,txtBody.text]; 



-(void) send:(id) sender { 
    [self sendEmailTo:@"[email protected]" withSubject:@"Contact for Quran Focus from iphone Application" withBody:message]; 

这就是我想要做的。 和EM收到错误

'txtName的' 不宣而这里(不是在一个函数)

'txtLoc' 不宣而这里(不是在一个函数) 'txtPho' 不宣而这里(不是在一个函数) “txtBody '这里没有声明(不是功能)

虽然我已经正确地宣布所有网点。

+0

concatenate - spelling :) – 2010-08-24 12:31:46

+0

@我的拼写呃上帝保佑我...... :) – 2010-08-24 12:56:59

回答

1

您需要将您的消息分配行放在send:function函数中,就在调用sendEmailTo之前:withSubject:withBody :.

+0

hhahah我犯了一个错误。谢谢汤米 – 2010-08-25 07:56:41

6
NSString *result = [NSString stringWithFormat:@"Student Name is %@ and He is from %@", txtName.text, txtLoc.text]; 
+0

只有txtName.text,而不仅仅是txtName – Vladimir 2010-08-24 12:28:10

+0

是的,注意到第二张贴。 – 2010-08-24 12:29:56

+0

Thansk我已经这样做了,但他们仍然得到这个错误......“'txtName'undeclared here(not in a function)” – 2010-08-24 12:40:46

1
NSString *outputString=[NSString stringWithFormat:@"Student Name is %@ and he is from %@",txtName.text,txtLoc.text]; 
0

获得从每个的UITextField([txtName的文本])的文本字符串,并使用stringByAppendingString方法:

combinedString = [[txtName的文本] stringByAppendingString:[txtLoc文本]]

相关问题