summaryrefslogtreecommitdiffstats
path: root/macosx/HBCodingUtilities.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBCodingUtilities.m')
-rw-r--r--macosx/HBCodingUtilities.m43
1 files changed, 43 insertions, 0 deletions
diff --git a/macosx/HBCodingUtilities.m b/macosx/HBCodingUtilities.m
new file mode 100644
index 000000000..8cf7e02bd
--- /dev/null
+++ b/macosx/HBCodingUtilities.m
@@ -0,0 +1,43 @@
+//
+// HBCodingUtilities.m
+// HandBrake
+//
+// Created by Damiano Galassi on 22/04/15.
+//
+//
+
+#import "HBCodingUtilities.h"
+
+static BOOL useSecureCoding;
+
+@implementation HBCodingUtilities
+
++ (void)initialize
+{
+ static BOOL initialized = NO;
+ if(!initialized && self == [HBCodingUtilities class]) {
+ useSecureCoding = NSProtocolFromString(@"NSSecureCoding") ? YES : NO;
+ }
+}
+
++ (id)decodeObjectOfClass:(Class)aClass forKey:(NSString *)key decoder:(NSCoder *)decoder
+{
+ if (useSecureCoding)
+ {
+ return [decoder decodeObjectOfClass:aClass forKey:key];
+ }
+ else
+ {
+ id obj = [decoder decodeObjectForKey:key];
+ if (![obj isKindOfClass:aClass])
+ {
+ return nil;
+ }
+ else
+ {
+ return obj;
+ }
+ }
+}
+
+@end