在我的應用程序中,我必須讀取一個XML文件並將其顯示在UITextView
中。爲此,我嘗試了下面的代碼。此代碼導致崩潰;任何人都可以告訴我確切的錯誤?我希望我寫得很好。請幫助我。謝謝。使用stringWithContentsOfFile讀取文件的問題:
-(IBAction)xmlParse{
NSString *xmlPath=[[[[UIApplication sharedApplication]delegate] applicationDocumentDirectory]stringByAppendingPathComponent:@"xmlFile/toc.xml"];
NSError *error=nil;
NSString *fileContent=[NSString stringWithContentsOfFile:xmlPath usedEncoding:NSASCIIStringEncoding error:NULL];
xmlDisplay.text=fileContent;
}
請加上控制檯錯誤消息。 – 2011-03-23 13:37:55