2011-04-18 84 views
0

我很抱歉的问题,但我已经搜查,但我还没有找到解决方案。 我有一个textField,我想为我的textField文本添加一个caractère。请问该怎么做?问题NSString

if (myConddition) { 

otherTextField.text = myTextField.text (a would like to add a caractér("1") to the first position). 

谢谢您的回答

回答

1
otherTextField.text = [NSString stringWithFormat:@"1%@", myTextField.text]; 
0

使用下面

NSMutableString* myString = [NSMutableString alloc] appendFormat:@"%@%@",@"1", myTextField.text]]; 
myTextField.text = myString; 
[myString release]; 
0
otherTextField.text = [@"1" stringByAppendingString:myTextField.text]; 
0

假设你已经创建@property声明...

[[self otherTextField] setText:[NSString stringWithFormat:@"1%@", [[self myTextField] text]]]; 

P.S. Eww在你男孩和女孩使用dot notation