-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *theXML = [[NSString alloc] initWithBytes: [myWebData mutableBytes] length:[myWebData length] encoding:NSUTF8StringEncoding];
NSLog(@"%@",theXML);
[self actualString:theXML
extractMyData:@"<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><GetCategoryResponse xmlns=\"http://tempuri.org/\"><GetCategoryResult>"
endingString:@"</GetCategoryResult></GetCategoryResponse></soap:Body></soap:Envelope>"
emptyString:@"<Prop_Category />"];
[theXML writeToFile:[self GetMyFilePath] atomically:YES encoding:NSStringEncodingConversionAllowLossy error:nil];
[theXML release];
}
-(NSArray*)actualString:(NSString*)theXML extractMyData:(NSString*)prefixString endingString:(NSString*)suffixString emptyString:(NSString*)noDataFromXMLString{
// now here I want to extract data from string
// from theXML
}
-(NSString*)GetMyFilePath{
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentDirectory=[paths objectAtIndex:0];
NSString *pathToUserCopyofplist=[documentDirectory stringByAppendingPathComponent:@"myWebServiceData.plist"];
NSLog(@"%@",pathToUserCopyofplist);
return pathToUserCopyofplist;
}
I want to save to response of asp.net web service in a plist file.
But sometimes, when response may be in a huge size. In such situation connection has received data more then 50,000 bytes. And when I NSlogs NSString – it prints (null).
In this case I can’t store web service response to the file.
What should be solution for this? Is there any alternate way of NSString? (for this purpose)
If you want to store something, you already have the bytes:
[myWebData mutableBytes]