1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
notifications-for-youtube/Notifications for YouTube/NYTChannelRestriction.m
Kim Wittenburg 15062dfb27 Archive Project
2017-07-25 17:21:13 +02:00

70 lines
1.7 KiB
Objective-C
Executable File

//
// NYTChannelRestrictions.m
// Notifications for YouTube
//
// Created by Kim Wittenburg on 21.07.13.
// Copyright (c) 2013 Kim Wittenburg. All rights reserved.
//
#import "NYTChannelRestriction.h"
// Core Imports
#import "NYTUtil.h"
@implementation NYTChannelRestriction
+ (NSSet *)keyPathsForValuesAffectingLocalizedRestrictionSummary
{
return [NSSet setWithObjects:@"disableAllNotifications", @"predicate", nil];
}
- (id)init
{
self = [super init];
if (self) {
// Default values
_positivePredicate = YES;
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [self init];
if (self) {
// Do not decode the user
_disableAllNotifications = [aDecoder decodeBoolForKey:@"Disable All Notifications"];
_predicate = [aDecoder decodeObjectForKey:@"Predicate"];
_positivePredicate = [aDecoder decodeBoolForKey:@"Positive Predicate"];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder
{
// Do not encode the user
[aCoder encodeBool:self.disableAllNotifications forKey:@"Disable All Notifications"];
[aCoder encodeObject:self.predicate forKey:@"Predicate"];
[aCoder encodeBool:self.positivePredicate forKey:@"Positive Predicate"];
}
- (NSString *)localizedRestrictionSummary
{
if (self.disableAllNotifications) {
return NSLocalizedString(@"No notifications", nil);
} else {
if (!self.predicate) {
return NSLocalizedString(@"Show all notifications", nil);
} else {
return NSLocalizedString(@"Restrict notifications", nil);
}
}
}
- (BOOL)differsFromDefaultValues
{
return self.disableAllNotifications == YES || self.predicate != nil;
}
@end