So +(id)dataWithContentsOfMappedFile:(NSString *)path is apparently deprecated since iOS 5.0. It sounds to me like I should avoid using it, but then what should I use instead?
I was using mmap to create memory mapped files and it worked with iOS5, but in iOS6, something is wrong because I get an error as soon as I try to update or read the buffer.
int fd = open(path, O_RDWR);
off_t offset = 0;
snapshotData = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
close(fd);
Use +dataWithContentsOfFile:options:error:
. Pass NSDataReadingMappedIfSafe
as the option. You can also use NSDataReadingMappedAlways
instead, but I recommend the former unless it really has to be mapped. If it really must be mapped, NSDataReadingMappedAlways
is still just a hint, so there's no promise. To get a promise, you need to write it yourself, as discussed at CIMG.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With