Open eikefalkenberg opened 5 years ago
I'm working on creating a modernized NSFileHandle+ARKAdditions
in https://github.com/dfed/CacheAdvance/pull/1, though I'm not sure if the current owners of this library would want to introduce that dependency.
One complication (which I haven't yet solved in CacheAdvance
) is that the new methods are iOS 13+, so we'd need to continue using the old methods in iOS 12, though we could wrap the old methods and have them return an error (or throw
in Swift).
Sounds great! The problem for this one in particular is that it runs asynchronous on it's own queue, so you can't handle the exception or a return error. A low hanging fruit here would be to just ignore the error with the new api.
Oh sorry now I see it, I missed that it's a new method, so we might have to wrap it in something like
if (@available(iOS 13.0, *)) {
NSError *error;
[self writeData:dataLengthData error:&error];
[self writeData:dataBlock error:&error];
} else {
@try {
[self writeData:dataLengthData];
[self writeData:dataBlock];
}
@catch ( NSException *e ) {
}
}
There are several calls to NSFileHandle's writeData in
NSFileHandle+ARKAdditions.m
which is deprecated.The problem here is that this old method will raise an exception in case of an error, especially if the device runs out of disk space:
Using the newer
writeData:error:
selector would return an error instead of causing an exception.