ios - 将 NSString 转换为其他 NSString

标签 ios objective-c nsstring

我有 3 个 NSString 和 1 个带值的 NSArray,我尝试将所有字符串转换为一个:

string01 = [string01 stringByAppendingString:[numbersValue objectAtIndex:Value1 -1]];
string03 = [string02 stringByAppendingString:[numbersValue objectAtIndex:Value2 -1]];
string03 = [string03 stringByAppendingString:[numbersValue objectAtIndex:Value3 -1]];

//here i will to convert value of striing01 in to string02 and string02 in to string03 than take last string in my UITextView

resulteString = [resulteString stringByAppendingString:<what i can write here?>];

[myTextView setText:resulteString];

就像一台谜机,例如,如果你想到键盘并按 A,

A pass inside a string01 and become B,
B pass inside a string02 and become C,
C pass inside string03 and become D
in my text view i need to see only D 

最佳答案

如果 resulteString 是 NSString 类的对象 然后使用

resultString = [NSString stringWithFormat:@"%@%@%@%@", resultString,string01, string02, string03];

否则如果 resulteString 是 NSMutableString 类的对象

   resulteString = [resulteString stringByAppendingFormat:@"%@%@%@", string01, string02, string03];

可能对你有帮助。

关于ios - 将 NSString 转换为其他 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29234587/

相关文章:

UILabel + UIButton iOS 本地化最佳实践

objective-c - 如何将 UITableViewCell 中的按钮与其操作方法连接起来

iphone - 在标签栏上设置背景图像

iphone - 如何比较 NSDates 以查找数组中最早和最晚的日期?

ios - 返回方法在完成 block 中失败

iphone - 从 NSString 中去除 12 小时制后缀

ios - Apple 第二次拒绝了我的应用

ios - 在 MKMapView 中围绕当前位置添加随机 MKAnnotations

objective-c - UIGestureRecognizers 冲突

iphone - 如何让底部的那些小 View 出现在 iOS SDK 中?