开发者

how to write a xml data in to plist file in iphone?

开发者 https://www.devze.com 2023-03-27 09:46 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消