how to write a xml data in to plist file in iphone?
how to write a xml data in to plist file in iphone? i am using this code ` i m use this code
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {NSString *thexml=[[NSString alloc] initWithBytes:[webdata mutableBytes] length:[webdata length] encoding:NSASCIIStringEncoding];
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//make a file name to write the data to using the documents directory:
// NSString *path = [[NSBundle mainBundle] pathForResource:@"mySettings" ofType:@"plist"]; NSString *fileName = [NSString stringWithFormat:@"%@/textfile.plist",
documentsDirectory];
//create content - four lines of t开发者_如何学编程ext
//NSString *content = @"One\nTwo\nThree\nFour\nFive";
NSString *content =thexml;
NSLog(@"%@",thexml);
//save content to the documents directory
[content writeToFile:fileName
atomically:YES
encoding:NSStringEncodingConversionAllowLossy
error:nil];
[self writePlist:1 fileName:thexml]; [thexml release]; [connection release];`
but i m see the plist file that display a file is a curuupted .?? pls give me a solution .... thanks in advance
精彩评论