Add secure coding to SPUUserUpdateState

This commit is contained in:
Zorg committed 2021-05-09 22:51:50 -07:00
1 parent 25b3d01efa
commit 1565db3fec
2 files changed
+26 -1

No files matched your search

+25
View File
@@ -12,6 +12,10 @@
#include "AppKitPrevention.h"
#define SPUUserUpdateStateStageKey @"SPUUserUpdateStateStage"
#define SPUUserUpdateStateUserInitiatedKey @"SPUUserUpdateStateUserInitiated"
#define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade"
@implementation SPUUserUpdateState
@synthesize stage = _stage;
@@ -29,4 +33,25 @@
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeInteger:self.stage forKey:SPUUserUpdateStateStageKey];
[encoder encodeBool:self.userInitiated forKey:SPUUserUpdateStateUserInitiatedKey];
[encoder encodeBool:self.majorUpgrade forKey:SPUUserUpdateStateMajorUpgradeKey];
}
- (instancetype)initWithCoder:(NSCoder *)decoder
{
SPUUserUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey];
BOOL userInitiated = [decoder decodeBoolForKey:SPUUserUpdateStateUserInitiatedKey];
BOOL majorUpgrade = [decoder decodeBoolForKey:SPUUserUpdateStateMajorUpgradeKey];
return [self initWithStage:stage userInitiated:userInitiated majorUpgrade:majorUpgrade];
}
+ (BOOL)supportsSecureCoding
{
return YES;
}
@end
+1 -1
View File
@@ -20,7 +20,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface SUAppcastItem (Private)
@interface SUAppcastItem (Private) <NSSecureCoding>
// Initializes with data from a dictionary provided by the RSS class.
- (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error;