mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 17:32:17 +00:00
Using representedObject instead of custom property
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
@property (copy, readonly) NSString *generatedPassword;
|
@property (copy, readonly) NSString *generatedPassword;
|
||||||
@property (weak) id closeTarget;
|
@property (weak) id closeTarget;
|
||||||
@property (nonatomic, weak) KPKEntry *entry;
|
|
||||||
@property (assign) BOOL allowsEntryDefaults;
|
@property (assign) BOOL allowsEntryDefaults;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)_setDefault:(id)sender {
|
- (IBAction)_setDefault:(id)sender {
|
||||||
if(self.useEntryDefaults && self.entry) {
|
if(self.useEntryDefaults && self.representedObject) {
|
||||||
NSMutableDictionary *entryDefaults = [[self _currentEntryDefaults] mutableCopy];
|
NSMutableDictionary *entryDefaults = [[self _currentEntryDefaults] mutableCopy];
|
||||||
if(!entryDefaults) {
|
if(!entryDefaults) {
|
||||||
entryDefaults = [[NSMutableDictionary alloc] initWithCapacity:4]; // we will only add one enty to new settings
|
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 {
|
- (void)setRepresentedObject:(id)representedObject {
|
||||||
if(_entry != entry) {
|
if(self.representedObject != representedObject) {
|
||||||
_entry = entry;
|
|
||||||
self.useEntryDefaults = [self _hasValidDefaultsForCurrentEntry];
|
self.useEntryDefaults = [self _hasValidDefaultsForCurrentEntry];
|
||||||
}
|
}
|
||||||
|
[super setRepresentedObject:representedObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPassword:(NSString *)password {
|
- (void)setPassword:(NSString *)password {
|
||||||
@@ -296,8 +296,9 @@ typedef NS_ENUM(NSUInteger, MPPasswordRating) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)_currentEntryDefaults {
|
- (NSDictionary *)_currentEntryDefaults {
|
||||||
if(self.entry) {
|
if(self.representedObject) {
|
||||||
return [self _availableEntryDefaults][[self.entry.uuid UUIDString]];
|
NSAssert([self.representedObject isKindOfClass:[KPKEntry class]], @"Only KPKEntry as represented object supported!");
|
||||||
|
return [self _availableEntryDefaults][[self.representedObject uuid].UUIDString];
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user