diff options
Diffstat (limited to 'macosx/HBCodingUtilities.h')
-rw-r--r-- | macosx/HBCodingUtilities.h | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/macosx/HBCodingUtilities.h b/macosx/HBCodingUtilities.h index c880e08aa..8635720ea 100644 --- a/macosx/HBCodingUtilities.h +++ b/macosx/HBCodingUtilities.h @@ -17,40 +17,13 @@ #define decodeInteger(x) x = [decoder decodeIntegerForKey:OBJC_STRINGIFY(x)] #define decodeBool(x) x = [decoder decodeBoolForKey:OBJC_STRINGIFY(x)] #define decodeDouble(x) x = [decoder decodeDoubleForKey:OBJC_STRINGIFY(x)] -#define decodeObject(x, cl) x = [HBCodingUtilities decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x) decoder:decoder]; +#define decodeObject(x, cl) x = [decoder decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x)]; -#define decodeCollectionOfObjects(x, cl, objectcl) x = [HBCodingUtilities decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], nil] forKey:OBJC_STRINGIFY(x) decoder:decoder]; +#define decodeCollectionOfObjects(x, cl, objectcl) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], nil] forKey:OBJC_STRINGIFY(x)]; -#define decodeCollectionOfObjects2(x, cl, objectcl, objectcl2) x = [HBCodingUtilities decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], nil] forKey:OBJC_STRINGIFY(x) decoder:decoder]; +#define decodeCollectionOfObjects2(x, cl, objectcl, objectcl2) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], nil] forKey:OBJC_STRINGIFY(x)]; -#define decodeCollectionOfObjects3(x, cl, objectcl, objectcl2, objectcl3) x = [HBCodingUtilities decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], [objectcl3 class], nil] forKey:OBJC_STRINGIFY(x) decoder:decoder]; +#define decodeCollectionOfObjects3(x, cl, objectcl, objectcl2, objectcl3) x = [decoder decodeObjectOfClasses:[NSSet setWithObjects:[cl class], [objectcl class], [objectcl2 class], [objectcl3 class], nil] forKey:OBJC_STRINGIFY(x)]; -#define decodeObjectOrFail(x, cl) x = [HBCodingUtilities decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x) decoder:decoder]; if (x == nil) {NSLog(@"Failed to decode: %@", OBJC_STRINGIFY(x)); goto fail;} - -NS_ASSUME_NONNULL_BEGIN - -@interface HBCodingUtilities : NSObject - -/** - * Specify what the expected class of the allocated object is. If the coder responds YES to -requiresSecureCoding, - * then an exception will be thrown if the class to be decoded does not implement NSSecureCoding or is not isKindOfClass: of the argument. - * If the coder responds NO to -requiresSecureCoding, then the class argument is ignored - * and no check of the class of the decoded object is performed, exactly as if decodeObjectForKey: had been called. - * - * if NSSecureCoding is not available on the system it check the class after loading the object. - * - * @param aClass The expect class type. - * @param key The coder key. - * @param decoder The NSCoder. - * - * @return the decoder object. - */ -+ (nullable id)decodeObjectOfClass:(Class)aClass forKey:(NSString *)key decoder:(NSCoder *)decoder; - - -+ (nullable id)decodeObjectOfClasses:(NSSet *)classes forKey:(NSString *)key decoder:(NSCoder *)decoder; - -@end - -NS_ASSUME_NONNULL_END +#define decodeObjectOrFail(x, cl) x = [decoder decodeObjectOfClass:[cl class] forKey:OBJC_STRINGIFY(x)]; if (x == nil) {NSLog(@"Failed to decode: %@", OBJC_STRINGIFY(x)); goto fail;} |