Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将NSString与其他NSString转换_Ios_Objective C_Nsstring - Fatal编程技术网

Ios 将NSString与其他NSString转换

Ios 将NSString与其他NSString转换,ios,objective-c,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 stringByAppen

我有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];

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

否则,如果ResultTestString是NSMutableString类的对象

   resulteString = [resulteString stringByAppendingFormat:@"%@%@%@", string01, string02, string03];
可能会帮助您。

使用此功能

[NSArray componentsJoinedByString]
你可以像下面这样使用

First write
in YourController.h file NSString *newString;

// Add below line in viewDidLoad
newString = @""; 
// In Your function
// A pressed from keyboard
NSString *str1 = @"Newly pressed Keyboard Key";  
// Add New Pressed key with existing one
newString = [NSString stringWithFormat:@"%@ %@",newString,str1];
通过这种方式,您可以将其添加到一个函数中,并在用户按下键盘上的任意键时调用


希望这能对你有所帮助。

我理解你的意思。如果要通过移位加密字符串,则需要以下方法:

//Edit this method how you want to use this is just an example
-(NSString *) encodeString:(NSString *) realString{
    NSArray *alphabet=[NSArray arrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"R",@"S",@"T",@"U",@"V",@"W",@"Y",@"Z",nil];
    int index=[alphabet indexOfObject:realString];
    index ++;
    NSString *resultString=[alphabet objectAtIndex:index];
    return resultString;

}
你需要一个字一个字地写这个字。使用UITextField的委托 每次你们点击键盘,调用这个方法,你们就会得到新的字符串。每次都将此字符串附加到另一个字符串


希望它能起作用。

您只想连接string01、string02和string03吗<代码>[NSString stringWithFormat:@“%@%@”,string01,string02,string03]请添加一个示例。这不是谜,而是ROT-3这不是谜,而是凯撒密码。我有一个午夜解码机长可以做到这一点@vikingosegundo ROT-3,如果代码没有那么多缺陷,但OP似乎正在尝试获取RORT-3。代码的第二行是错误的。我知道,您将指定给string03而不是string02.Thks,但我只需要一个结果,例如,如果您认为一个键盘并按下a,string01中的一个过程将变为B,string02中的B过程将变为C,C在string03中传递,在我的文本视图中变成D,我只需要看到D请看我的描述添加Nowseed和appendString函数似乎合理,但它有什么问题?我必须更改一个值,使用此方法,我可以同时得到所有结果
First write
in YourController.h file NSString *newString;

// Add below line in viewDidLoad
newString = @""; 
// In Your function
// A pressed from keyboard
NSString *str1 = @"Newly pressed Keyboard Key";  
// Add New Pressed key with existing one
newString = [NSString stringWithFormat:@"%@ %@",newString,str1];
//Edit this method how you want to use this is just an example
-(NSString *) encodeString:(NSString *) realString{
    NSArray *alphabet=[NSArray arrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"R",@"S",@"T",@"U",@"V",@"W",@"Y",@"Z",nil];
    int index=[alphabet indexOfObject:realString];
    index ++;
    NSString *resultString=[alphabet objectAtIndex:index];
    return resultString;

}