download XML file from server
hi guys,i parse my file xml from my server
NSString *theXML = [[NSString alloc] initWithBytes: [Conn.webData mutableBytes] length:[Conn.webData length] encoding:NSUTF8StringEncoding];
//NSLog(theXML);
[theXML release];
but now i want download this file in my iPhone,it possible to do this?
i see this exemple but i not undersund :
NSString *path=[NSTemporaryDirectory() stringByAppendingString:@"file.txt"];
// save the people array
BOOL saved=[NSKeyedArchiver archiveRootObject:people toFile:path];
if(saved){
//NSLog(@"saved");
}else{
//NSLog(@"Not saved");
};
// r开发者_如何学JAVAeload array
people=[NSKeyedUnarchiver unarchiveObjectWithFile:path];
if(newArray==nil)
{
// create new array
people=[[NSMutableArray alloc] init];
}else{
// retener los datos
[perople retain];
};
You can use NSData *data=[NSData dataWithContentsOfURL: options: error:] and [data writeToFile: options:1 error:]; for doing this.
精彩评论