Archive Project
This commit is contained in:
69
Notifications for YouTube/NYTChannelRestriction.m
Executable file
69
Notifications for YouTube/NYTChannelRestriction.m
Executable file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user