2011-07-04 3 views
0

저는 iPhone 용 응용 프로그램을 개발하고 있습니다.이 응용 프로그램에서는 C++ CLucene 라이브러리를 가져 왔습니다. 거의 모든 CLucene 기능은 StringTCHAR*으로 요구합니다.(CLucene을 사용하여) TCHAR과 NSString을 변환하는 방법 (CLucene 사용)

NSString을이 유형의 데이터로 변환하는 데 문제가 있습니다. 나는 많은 해결책을 찾았지 만 아무도 효과가 없었다.

변환 방법을 알려주십시오.

with _T() 매크로로 정의 된 테스트 문자열로 라이브러리 작업을 할 수있었습니다. 그러나 XCode는 나를 주겠다 :

Conversion from string literal to 'TCHAR *' (aka 'wchar_t *') is deprecated. 

나는 그것을하기 위해 더 이상 사용되지 않는 방법은 무엇입니까?

감사합니다.

편집 :

NSStringTCHAR*까지 변환 :

(const TCHAR *) [stringa cStringUsingEncoding:NSUTF32LittleEndianStringEncoding]; 

TCHAR* NSString까지 변환 :

[[NSString alloc] initWithBytes:ctc length:wcslen(ctc) * sizeof(TCHAR) encoding:NSUTF32LittleEndianStringEncoding] 

당신을 감사 나는이 방법으로 해결!

+0

(http://stackoverflow.com/questions/2610871/how-to-copy-a-wchar- t-into-an-nsstring)과 ['this'] (http://stackoverflow.com/questions/891594/nsstring-to-wchar-t)를 참조하십시오. –

답변

0

다음 코드는 나를 위해 일한 :

NSString *pStr = [NSString stringWithFormat:@"%S", GetTCHARString()]; 
당신은 [`this`]에서 볼 수도 있습니다
관련 문제