Silence ‘decodeObjectOfClass:forKey: is only available on macOS 10.8’ Xcode warnings, similar to commit ea94969188

This commit is contained in:
Dave Wood committed 2018-03-25 23:05:25 -04:00
1 parent 189ed9d315
commit 79511c982a
1 file changed
+13 -9
+13 -9
View File
@@ -52,16 +52,20 @@ static NSString *SPUDownloadMIMETypeKey = @"SPUDownloadMIMEType";
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
{
NSData *data = [decoder decodeObjectOfClass:[NSData class] forKey:SPUDownloadDataKey];
if (data == nil) {
return nil;
if (@available(macOS 10.8, *)) {
NSData *data = [decoder decodeObjectOfClass:[NSData class] forKey:SPUDownloadDataKey];
if (data == nil) {
return nil;
}
NSString *textEncodingName = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadTextEncodingKey];
NSString *MIMEType = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadMIMETypeKey];
return [self initWithData:data textEncodingName:textEncodingName MIMEType:MIMEType];
} else {
abort(); // Not used on 10.7
}
NSString *textEncodingName = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadTextEncodingKey];
NSString *MIMEType = [decoder decodeObjectOfClass:[NSString class] forKey:SPUDownloadMIMETypeKey];
return [self initWithData:data textEncodingName:textEncodingName MIMEType:MIMEType];
}
@end