I know My question may be lengthy, but I want to share my experience please help me out with an explaination. I am getting a huge Json response from server, and I am storing it into a Dictionary.when I am printing the Dictionary it is showing (null).Can anybody please explain why it is happening like that?
After a little research I am saving the huge Json response to a file and I am able to read the Json from that file.Firstly it worked fine but now I am getting this error
Error Domain=NSCocoaErrorDomain Code=3840 "Unable to convert data to string around character 1070." UserInfo={NSDebugDescription=Unable to convert data to string around character 1070.}
This is how I am writing json to a file
-(void)writeJsonDatatoFile:(NSData*)jsonData
{
NSError *errorWriting;
NSString *dest=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] stringByAppendingPathComponent:@"file.json"];
[jsonData writeToFile:dest atomically:YES];
}
This is how I am reading json from file
-(void*)readJsonDataFromFile
{
NSString *source=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0] stringByAppendingPathComponent:@"file.json"];
NSError *error;
NSError *error1;
NSData *data=[NSData dataWithContentsOfFile:source options:kNilOptions error:&error1];
NSLog(@"Reading Error--%@",error1);
NSDictionary *dataDict=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"json Data From File--%@-%@",dataDict,error);
}