2010-07-29 2 views
0
self.pdfPath = [[NSBundle mainBundle] pathForResource:@"iPhone_SDK_License" ofType:@"pdf"]; 
NSData *htmlData = [NSData dataWithContentsOfFile:pdfPath]; 
NSString *htmlstr = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; 

htmlstr에 nil이 표시되어 있으므로 도움이 필요합니다.문자열의 데이터를 검색 할 수 없습니다.

+0

더 많이 디버깅해야합니다. pdfPath는 nil입니까? htmlData는 nil입니까? – jtbandes

답변

0

pdf는 HTML 파일이 아니므로 initWithData : encoding :이 데이터를 이해할 수 없으므로 실패합니다.

stringWithContentsOfURL:encoding:error:을 사용하여 오류의 세부 정보를 확인하십시오.

+0

다시 쓰레기 ​​값을 표시하므로 내 코드를 다음과 같이 찾으십시오. 코드 self.pdfPath = [[NSBundle mainBundle] pathForResource : @ "iPhone_SDK_License"ofType : @ "pdf"]; \t self.pdfUrl = [NSURL fileURLWithPath : pdfPath]; \t [webView loadRequest : [NSURLRequest requestWithURL : pdfUrl]]; NSString * myString = [NSString stringWithContentsOfURL : pdfUrl]; \t [fliteEngine speakText : myString]; \t NSLog (@ "myString % @", myString); – Umaid

+0

오류가 표시 될 때 어떤 인코딩을 사용해야합니까? – Umaid

+0

NSError는 무엇을 표시합니까? – Mark

관련 문제