Revision: 12919
          http://sourceforge.net/p/skim-app/code/12919
Author:   hofman
Date:     2022-05-11 14:23:13 +0000 (Wed, 11 May 2022)
Log Message:
-----------
don't use deprecated NSPropertyListSerialization methods

Modified Paths:
--------------
    trunk/SkimNotes/SKNDocument.m
    trunk/SkimNotes/SKNExtendedAttributeManager.m
    trunk/SkimNotes/SKNUtilities.m
    trunk/SkimNotes/skimnotes.m

Modified: trunk/SkimNotes/SKNDocument.m
===================================================================
--- trunk/SkimNotes/SKNDocument.m       2022-05-11 09:42:24 UTC (rev 12918)
+++ trunk/SkimNotes/SKNDocument.m       2022-05-11 14:23:13 UTC (rev 12919)
@@ -128,7 +128,7 @@
             @try { array = [NSKeyedUnarchiver unarchiveObjectWithData:data]; }
             @catch (id e) {}
             if (array == nil)
-                array = [NSPropertyListSerialization propertyListFromData:data 
mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:NULL];
+                array = [NSPropertyListSerialization propertyListWithData:data 
options:NSPropertyListImmutable format:NULL error:NULL];
         }
     }
 
@@ -191,7 +191,7 @@
             @try { array = [NSKeyedUnarchiver unarchiveObjectWithData:data]; }
             @catch (id e) {}
             if (array == nil)
-                array = [NSPropertyListSerialization propertyListFromData:data 
mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:NULL];
+                array = [NSPropertyListSerialization propertyListWithData:data 
options:NSPropertyListImmutable format:NULL errorDescription:NULL];
         } else {
             array = [NSArray array];
         }

Modified: trunk/SkimNotes/SKNExtendedAttributeManager.m
===================================================================
--- trunk/SkimNotes/SKNExtendedAttributeManager.m       2022-05-11 09:42:24 UTC 
(rev 12918)
+++ trunk/SkimNotes/SKNExtendedAttributeManager.m       2022-05-11 14:23:13 UTC 
(rev 12919)
@@ -261,9 +261,7 @@
     }
     
     if (namePrefix && [self isPlistData:attribute]) {
-        NSPropertyListFormat format;
-        NSString *errorString;
-        id plist = [NSPropertyListSerialization propertyListFromData:attribute 
mutabilityOption:NSPropertyListImmutable format:&format 
errorDescription:&errorString];
+        id plist = [NSPropertyListSerialization propertyListWithData:attribute 
options:NSPropertyListImmutable format:NULL error:NULL];
         
         // even if it's a plist, it may not be a dictionary or have the key 
we're looking for
         if (plist && [plist respondsToSelector:@selector(objectForKey:)] && 
[[plist objectForKey:wrapperKey] boolValue]) {
@@ -331,14 +329,12 @@
             if (error) *error = [NSError 
errorWithDomain:SKNSkimNotesErrorDomain code:SKNInvalidDataError 
userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"Invalid data.", @"Error 
description"), NSLocalizedDescriptionKey, nil]];
 
         } else {
-            NSString *errorString;
-            plist = [NSPropertyListSerialization propertyListFromData:data
-                                                     
mutabilityOption:NSPropertyListImmutable
+            plist = [NSPropertyListSerialization propertyListWithData:data
+                                                              
options:NSPropertyListImmutable
                                                                format:NULL
-                                                     
errorDescription:&errorString];
+                                                                
error:&anError];
             if (nil == plist) {
-                if (error) *error = [NSError 
errorWithDomain:SKNSkimNotesErrorDomain code:SKNPlistDeserializationFailedError 
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:path, NSFilePathErrorKey, 
errorString, NSLocalizedDescriptionKey, nil]];
-                [errorString release];
+                if (error) *error = [NSError 
errorWithDomain:SKNSkimNotesErrorDomain code:SKNPlistDeserializationFailedError 
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:path, NSFilePathErrorKey, 
[anError localizedDescription], NSLocalizedDescriptionKey, nil]];
             }
         }
     }
@@ -375,7 +371,7 @@
         NSString *uniqueValue = [self uniqueName];
         NSUInteger numberOfFragments = ([value length] / MAX_XATTR_LENGTH) + 
([value length] % MAX_XATTR_LENGTH ? 1 : 0);
         NSDictionary *wrapper = [NSDictionary 
dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], wrapperKey, 
uniqueValue, uniqueKey, [NSNumber numberWithUnsignedInteger:numberOfFragments], 
fragmentsKey, nil];
-        NSData *wrapperData = [NSPropertyListSerialization 
dataFromPropertyList:wrapper format:NSPropertyListBinaryFormat_v1_0 
errorDescription:NULL];
+        NSData *wrapperData = [NSPropertyListSerialization 
dataWithPropertyList:wrapper format:NSPropertyListBinaryFormat_v1_0 options:0 
error:NULL];
         NSParameterAssert([wrapperData length] < MAX_XATTR_LENGTH && 
[wrapperData length] > 0);
         
         // we don't want to split this dictionary (or compress it)
@@ -419,14 +415,14 @@
 
 - (BOOL)setExtendedAttributeNamed:(NSString *)attr 
toPropertyListValue:(id)plist atPath:(NSString *)path 
options:(SKNXattrFlags)options error:(NSError **)error;
 {
-    NSString *errorString;
-    NSData *data = [NSPropertyListSerialization dataFromPropertyList:plist 
-                                                              
format:NSPropertyListBinaryFormat_v1_0 
-                                                    
errorDescription:&errorString];
+    NSError *anError = nil;
+    NSData *data = [NSPropertyListSerialization dataWithPropertyList:plist
+                                                              
format:NSPropertyListBinaryFormat_v1_0
+                                                             options:0
+                                                               error:&anError];
     BOOL success;
     if (nil == data) {
-        if (error) *error = [NSError errorWithDomain:SKNSkimNotesErrorDomain 
code:SKNPlistDeserializationFailedError userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:path, NSFilePathErrorKey, errorString, 
NSLocalizedDescriptionKey, nil]];
-        [errorString release];
+        if (error) *error = [NSError errorWithDomain:SKNSkimNotesErrorDomain 
code:SKNPlistDeserializationFailedError userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:path, NSFilePathErrorKey, [anError 
localizedDescription], NSLocalizedDescriptionKey, nil]];
         success = NO;
     } else {
         // if we don't split and the data is too long, compress the data using 
bzip to save space
@@ -476,12 +472,10 @@
             // let NSData worry about freeing the buffer
             NSData *attribute = [[NSData alloc] initWithBytesNoCopy:namebuf 
length:bufSize];
             
-            NSPropertyListFormat format;
-            NSString *errorString;
             id plist = nil;
             
             if (namePrefix && [self isPlistData:attribute])
-                plist = [NSPropertyListSerialization 
propertyListFromData:attribute mutabilityOption:NSPropertyListImmutable 
format:&format errorDescription:&errorString];
+                plist = [NSPropertyListSerialization 
propertyListWithData:attribute options:NSPropertyListImmutable format:NULL 
error:NULL];
             
             // even if it's a plist, it may not be a dictionary or have the 
key we're looking for
             if (plist && [plist respondsToSelector:@selector(objectForKey:)] 
&& [[plist objectForKey:wrapperKey] boolValue]) {

Modified: trunk/SkimNotes/SKNUtilities.m
===================================================================
--- trunk/SkimNotes/SKNUtilities.m      2022-05-11 09:42:24 UTC (rev 12918)
+++ trunk/SkimNotes/SKNUtilities.m      2022-05-11 14:23:13 UTC (rev 12919)
@@ -208,7 +208,7 @@
             @try { noteDicts = [NSKeyedUnarchiver 
unarchiveObjectWithData:data]; }
             @catch (id e) {}
         } else if (ch == 0xA || ch == 0x0) {
-            noteDicts = [NSPropertyListSerialization propertyListFromData:data 
mutabilityOption:NSPropertyListMutableContainers format:NULL 
errorDescription:NULL];
+            noteDicts = [NSPropertyListSerialization propertyListWithData:data 
options:NSPropertyListMutableContainers format:NULL error:NULL];
             if ([noteDicts isKindOfClass:[NSArray class]]) {
                 for (NSMutableDictionary *dict in noteDicts) {
                     id value;
@@ -330,7 +330,7 @@
                 [array addObject:dict];
                 [dict release];
             }
-            data = [NSPropertyListSerialization dataFromPropertyList:array 
format:NSPropertyListBinaryFormat_v1_0 errorDescription:NULL];
+            data = [NSPropertyListSerialization dataWithPropertyList:array 
format:NSPropertyListBinaryFormat_v1_0 options:0 error:NULL];
             [array release];
             [colors release];
         } else {

Modified: trunk/SkimNotes/skimnotes.m
===================================================================
--- trunk/SkimNotes/skimnotes.m 2022-05-11 09:42:24 UTC (rev 12918)
+++ trunk/SkimNotes/skimnotes.m 2022-05-11 14:23:13 UTC (rev 12919)
@@ -563,7 +563,7 @@
                 @try { inNotes = [NSKeyedUnarchiver 
unarchiveObjectWithData:data]; }
                 @catch (id e) {}
                 if (inNotes == nil) {
-                    inNotes = [NSPropertyListSerialization 
propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:NULL 
errorDescription:NULL];
+                    inNotes = [NSPropertyListSerialization 
propertyListWithData:data options:NSPropertyListImmutable format:NULL 
error:NULL];
                     isPlist = YES;
                 }
                 if ([inNotes isKindOfClass:[NSArray class]]) {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to