2009-07-18 5 views
0

내 iPhone 프로그램에서 sqlite 데이터베이스의 데이터를 가져옵니다. DB에서 얻은 정보는 UITextView에 저장됩니다. "따옴표" "그것은 가지고 안녕하세요 이것은 예입니다."문자열의 교체

"간단한로 끝나는"나는 하나 하나를 제거하고에 의해 이중 대체 할

: 페치 텍스트의 예는 싱글. 하지만 작동하지 않습니다. 여기 내 코드 :

NSString *question; 
question = [[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement1,1)] copy]; 
question = [question stringByReplacingOccurrencesOfString:@"\"\"" withString:@"$$"]; 
question = [question stringByReplacingOccurrencesOfString:@"\"" withString:@""]; 
question = [question stringByReplacingOccurrencesOfString:@"$$" withString:@"\""]; 

무엇이 잘못 되었나요?

대단히 감사합니다.

답변

1

코드는 정상적으로 보입니다. 나는

NSString *question = @"\"Hello this is a example. It has \"\" double quotes \"\" and ends with simple\""; 
question = [question stringByReplacingOccurrencesOfString:@"\"\"" withString:@"$$"]; 
question = [question stringByReplacingOccurrencesOfString:@"\"" withString:@""]; 
question = [question stringByReplacingOccurrencesOfString:@"$$" withString:@"\""]; 

을 수행하여 그것을 시도하고 괜찮 았는데 (옆에 따옴표로 사용되는 곳으로 여분의 공백이 있다는 사실을 제외하고, 음,하지만 당신이 원하는 것을 알고 어렵다)

일부

NSLog(@"question is now: %@", question); 

라인을 추가하면

당신은 아마 당신이 적어도 게시 할 수있는 좀 더 많은 정보를 가지고 있습니다하지 않을 경우에 가거나 무엇을 말할 수있을 것이다!