Substitute for NSData deprecated dataWithContentsOfMappedFile

后端 未结 1 950
春和景丽
春和景丽 2021-01-13 10:21

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 instea

相关标签:
1条回答
  • 2021-01-13 10:43

    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.

    0 讨论(0)
提交回复
热议问题