我需要在UITextView
中顯示RTF file
。我的代碼看起來像下面:錯誤消息NSData
我.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];
}
此代碼給我下面的錯誤消息:
at
*creditsData : Incompatible pointer types 'NSData *' with expression of type 'NSString *'
,並在
initWithRTF : No visible @interface for 'NSAttributedString' declares the selector 'initWithRTF:documentAttributes:'
如何解決這兩個錯誤?
什麼'[NSBundle pathForResource:ofType:]'然後呢?這當然不是「Credits.rtf」的內容...... – trojanfoe