Skip to content

Commit 9c2f82c

Browse files
committed
Replace all calls to deprecated method +propertyListFromData:mutabilityOption:format:errorDescription:
1 parent f4ac8ae commit 9c2f82c

11 files changed

+1005
-902
lines changed

Diff for: Source/GeneratePreviewForURL.m

+35-22
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,23 @@ void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview)
145145
#pragma mark -
146146

147147
NSString *PreviewForSPF(NSURL *myURL, NSInteger *previewHeight) {
148-
148+
NSDictionary *spf = nil;
149149
NSError *readError = nil;
150-
NSString *convError = nil;
151-
NSPropertyListFormat format;
152-
NSString *html = nil;
153-
150+
154151
// Get spf data as dictionary
155-
NSData *pData = [NSData dataWithContentsOfFile:[myURL path] options:NSUncachedRead error:&readError];
156-
NSDictionary *spf = [[NSPropertyListSerialization propertyListFromData:pData
157-
mutabilityOption:NSPropertyListImmutable
158-
format:&format
159-
errorDescription:&convError] retain];
152+
NSData *pData = [NSData dataWithContentsOfFile:[myURL path]
153+
options:NSUncachedRead
154+
error:&readError];
155+
156+
if(pData && !readError) {
157+
spf = [[NSPropertyListSerialization propertyListWithData:pData
158+
options:NSPropertyListImmutable
159+
format:NULL
160+
error:&readError] retain];
161+
}
160162

161-
if(!readError && spf && ![convError length] && (format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {
163+
NSString *html = nil;
164+
if(!readError && spf) {
162165
NSString *spfType = [spf objectForKey:SPFFormatKey];
163166
NSString *(*fp)(NSDictionary *spf,NSURL *myURL, NSInteger *previewHeight) = NULL;
164167
// Dispatch different spf formats
@@ -378,16 +381,21 @@ static inline void CopyIf(NSDictionary *src,NSString *key,NSMutableDictionary *d
378381
}
379382

380383
NSError *readError = nil;
381-
NSString *convError = nil;
382-
NSPropertyListFormat format;
383384
NSDictionary *spf = nil;
384385

385386
// Get info.plist data as dictionary
386-
NSData *pData = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/info.plist", [myURL path]] options:NSUncachedRead error:&readError];
387-
spf = [[NSPropertyListSerialization propertyListFromData:pData
388-
mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain];
387+
NSData *pData = [NSData dataWithContentsOfFile:[[myURL path] stringByAppendingPathComponent:@"info.plist"]
388+
options:NSUncachedRead
389+
error:&readError];
390+
391+
if(pData && !readError) {
392+
spf = [[NSPropertyListSerialization propertyListWithData:pData
393+
options:NSPropertyListImmutable
394+
format:NULL
395+
error:&readError] retain];
396+
}
389397

390-
if(!spf || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {
398+
if(!spf || readError) {
391399
[spf release];
392400
return nil;
393401
}
@@ -434,14 +442,19 @@ static inline void CopyIf(NSDictionary *src,NSString *key,NSMutableDictionary *d
434442
continue;
435443
}
436444
// Get info.plist data as dictionary
437-
NSDictionary *sessionSpf;
445+
NSDictionary *sessionSpf = nil;
438446
pData = [NSData dataWithContentsOfFile:spfPath options:NSUncachedRead error:&readError];
439-
sessionSpf = [[NSPropertyListSerialization propertyListFromData:pData
440-
mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError] retain];
447+
if(pData && !readError) {
448+
sessionSpf = [[NSPropertyListSerialization propertyListWithData:pData
449+
options:NSPropertyListImmutable
450+
format:NULL
451+
error:&readError] retain];
452+
}
441453

442-
if(!sessionSpf || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {
454+
if(!sessionSpf || readError) {
443455
[spfsHTML appendFormat:@"    %@ ∅", [tab objectForKey:@"path"]];
444-
} else {
456+
}
457+
else {
445458

446459
NSString *name = @"••••";
447460
NSString *host = @"••••";

0 commit comments

Comments
 (0)