我需要讀取文件。 plist或。 txt from url如何從文件和URL讀取(.plist或.txt)
例如。
http://www.nordenmovil.com/BuscadorTopTen/carros.plist
http://www.nordenmovil.com/BuscadorTopTen/texto.txt
NSString * path = @ "www.nordenmovil.com/BuscadorTopTen/carros.plist";
NSError * error;
NSString * stringFromFileAtPath = [[NSString alloc]
initWithContentsOfFile: path
encoding: NSUTF8StringEncoding
error: & error];
if (stringFromFileAtPath == nil) {
// An error occurred
NSLog (@ "Error reading file at% @ \ n% @",
path, [error localizedFailureReason]);
}
NSLog (@ "% @", stringFromFileAtPath);
你的問題是什麼? – WendiKidd 2012-07-18 23:58:18