Using representedObject instead of custom property

This commit is contained in:
michael starke
2016-08-23 18:34:02 +02:00
parent 0f0e187bc8
commit d640434012
2 changed files with 7 additions and 7 deletions

View File

@@ -13,7 +13,6 @@
@property (copy, readonly) NSString *generatedPassword;
@property (weak) id closeTarget;
@property (nonatomic, weak) KPKEntry *entry;
@property (assign) BOOL allowsEntryDefaults;
/**

View File

@@ -183,7 +183,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
}
- (IBAction)_setDefault:(id)sender {
if(self.useEntryDefaults && self.entry) {
if(self.useEntryDefaults && self.representedObject) {
NSMutableDictionary *entryDefaults = [[self _currentEntryDefaults] mutableCopy];
if(!entryDefaults) {
entryDefaults = [[NSMutableDictionary alloc] initWithCapacity:4]; // we will only add one enty to new settings
@@ -236,11 +236,11 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
}
}
- (void)setEntry:(KPKEntry *)entry {
if(_entry != entry) {
_entry = entry;
- (void)setRepresentedObject:(id)representedObject {
if(self.representedObject != representedObject) {
self.useEntryDefaults = [self _hasValidDefaultsForCurrentEntry];
}
[super setRepresentedObject:representedObject];
}
- (void)setPassword:(NSString *)password {
@@ -296,8 +296,9 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
}
- (NSDictionary *)_currentEntryDefaults {
if(self.entry) {
return [self _availableEntryDefaults][[self.entry.uuid UUIDString]];
if(self.representedObject) {
NSAssert([self.representedObject isKindOfClass:[KPKEntry class]], @"Only KPKEntry as represented object supported!");
return [self _availableEntryDefaults][[self.representedObject uuid].UUIDString];
}
return nil;
}