我试图在我的数组中获取一个字符串,将字符串中的第 n 个字母更改为?,然后在文本字段中打印结果。问题是我的 NSMutableArray 被存储到 UIPickerView 中,我认为最好从 PickerView 读取字符串,然后更改第 n 个字符并打印结果。我正在努力解决如何从选择器中获取字符串并更改第 n 个字母。
- (UIView *)viewForRow:(NSInteger)row forComponent:(NSInteger)component
{
if (row == 0 ) {
NSString *originalStringTwo = @"%@", *arrayDictionary;
NSRange two = [originalStringTwo rangeOfString:@"2"];
NSString *newStringTwo = [originalStringTwo stringByReplacingCharactersInRange:two withString:@"?"];
_resultLabel.text = newStringTwo;
}
if (row == 1 ) {
NSString *originalStringThree = @"%@", *arrayDictionary;
NSRange three = [originalStringThree rangeOfString:@"3"];
NSString *newStringThree = [originalStringThreestringByReplacingCharactersInRange:three withString:@"?"];
_resultLabel.text = newStringThree;
}
if ( row == 2 ) {
NSString *originalStringFour = @"%@", *arrayDictionary;
NSRange four = [originalStringFour rangeOfString:@"4"];
NSString *newStringFour = [originalStringFour stringByReplacingCharactersInRange:four withString:@"?"];
_resultLabel.text = newStringFour;
}
return 0;
}