에 표시해야 RTF file
합니다 UITextView
. 내 코드는 다음과 같습니다.
내 .h 파일 :
@property (strong, nonatomic) IBOutlet UITextView *creditsTextView;
내 .m 파일
@synthesize creditsTextView;
- (void)viewDidLoad {
[super viewDidLoad];
NSData *creditsData = [[NSBundle mainBundle] pathForResource:@"Credits" ofType:@"rtf"];
NSAttributedString *attrString;
NSDictionary *docAttributes;
attrString = [[NSAttributedString alloc]
initWithRTF: creditsData documentAttributes: &docAttributes];
}
이 코드는 다음과 같은 오류 메시지를 제공 합니다.
...에서
*creditsData : Incompatible pointer types 'NSData *' with expression of type 'NSString *'
그리고
initWithRTF : No visible @interface for 'NSAttributedString' declares the selector 'initWithRTF:documentAttributes:'
이 두 가지 오류를 어떻게 해결할 수 있습니까?
[[NSBundle mainBundle] pathForResource:
반환 type NSString
, NSBundle Class Reference 참조 , 따라서 NSData를 직접 할당 할 수 없으므로 NSString
반환 된 URL을 다른 이니셜 라이저를 사용하여 NSData에 전달할 수 있습니다.
그리고 NSAttributedString
라는 init 메서드가 없습니다 initWithRTF
. 이것이 오류가 표시되는 이유입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다