I am developing an iphone application that downloads a file UTF8Encodedfrom the server, saves it in the applicationβs Cache folder and simply copies its contents to NSString* var. It works on the device, but not on the simulator, here is the code:
NSLog(@"File loaded into path: %@\n", localPath);
NSError* error;
NSString* tmpString = [NSString stringWithContentsOfFile:localPath encoding:NSUTF8StringEncoding error:&error];
NSLog(@"Error: %@", error);
NSLog(@"tmpString length:%u", [tmpString length]);
On the simulator, this piece of code prints:
File loaded into path: /Users/username/Library/Application Support/iPhone Simulator/5.1/Applications/4FCF8FC6-4F1B-4FE5-92F6-A99EC8888E47/Library/Caches/utf8encodedFile.txt
But it crashes when it calls the " stringWithContentsOfFile:" method without displaying errors
Everything works well on a real device, it prints:
File loaded into path: /var/mobile/Applications/1EE8AEEB-D036-4ADE-AE12-836BA1F16BCB/Library/Caches/utf8encodedFile.txt
2012-06-30 19:19:24.743 appName[685:707]
Error: (null)
2012-06-30 19:19:24.745 appName[685:707] tmpString length:1423
source
share