I need to read a file. plist or. txt from a url
for example.
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);
So you use NSURLConnection, you give it the URL, you get back a data object. You then need to convert that object into something that you can deal with – that is, you find iOS classes that can convert that object to the desired format. Suppose the data is an image. Then you would use:
[UIImage imageWithData:];
Its similar for all other objects