입니다. 이전 질문에 대한 답변을 따르지 만 5 개의 문자열 배열을 하나의 큰 문자열로 결합해야하는 다음 코드를 실행할 때 오류가 발생합니다.NSAttributedStrings를 추가하면 오류가
NSArray *myStrings = [text componentsSeparatedByString:@"//"];
NSMutableAttributedString *result = [[NSMutableAttributedString alloc] init];
NSAttributedString *delimiter = [[NSAttributedString alloc] initWithString:@","];
NSLog(@"The Content of myStrings is %@", myStrings);
for (NSAttributedString *str in myStrings)
{
if (result.length)
{
[result appendAttributedString:delimiter];
}
[result appendAttributedString:str];
}
NSLog에서 출력이 반환
2013-06-11 20:49:55.012 strings[11789:11303] The Content of myStrings is (
"Hello ",
"my name is ",
"Giovanni ",
"and im pretty crap ",
"at ios development"
그래서 나는 5 문자열 배열을 알고.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString string]: unrecognized selector sent to instance 0x716ec60'
I : 그러나 코드 내지 제 실행 그것이 비록에, 그것은 'for'루프의 마지막 선에 에러가 발생 루프 '가'(예상대로) 바이 패스 왜 그럴까요? str과 result 모두 같은 유형의 문자열로 정의되었으므로 왜 다른 문자열에 추가 할 수 없는지는 알 수 없습니다. 아무 단서?
그게 정확히, 감사합니다! – Giovanni