2011-08-01 2 views
0

읽어야하는 IOS의 NSData 객체에 RTFD 데이터가 있습니다. MacOSX에서는 방금 NSAttributedString을 사용하여 읽었지만 이제는 IOS에서 지원되지 않습니다.IOS에서 RTFD 데이터 읽기

IOS에서 RTFD 데이터의 텍스트 만 읽을 수있는 방법이 있습니까?

+0

initWithRTFD : documentAttributes :가 지원되지 않지만 NSAttributedString 클래스는 iOS 3.2 이후 지원됩니다! – JustSid

+0

rtf를 읽을 때 사용할 수 있습니까? –

답변

0

iOS의 rtfd는 디렉토리와 같습니다. 텍스트 부분 만보고 싶다면 다음을 시도해보십시오.

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"photo" ofType:@"rtfd"]; 
NSFileManager *fileManager = [NSFileManager defaultManager]; 
NSArray *content = [fileManager contentsOfDirectoryAtPath:filePath error:nil]; 
NSString *textFilePath = [filePath stringByAppendingPathComponent:@"TXT.rtf"];//you can get the path component from the content; usually it is TXT.rtf 
NSError *error = nil; 
NSString *pureText = [[NSString alloc] initWithContentsOfFile:textFilePath encoding:NSASCIIStringEncoding error:&error]; 
NSLog(@"pureText:\n%@",pureText); 

희망이 있습니다.