Skip to content

Commit

Permalink
Merge pull request #94 from erichoracek/nullability
Browse files Browse the repository at this point in the history
Match nullability specifiers of NSObject initializers
  • Loading branch information
dfed authored Sep 29, 2016
2 parents 44754d8 + 444e535 commit 0a0ae2c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Valet.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Valet'
s.version = '2.2.2'
s.version = '2.2.3'
s.license = 'Apache License, Version 2.0'
s.summary = 'Valet lets you securely store data in the iOS or OS X Keychain without knowing a thing about how the Keychain works. It\'s easy. We promise.'
s.homepage = 'https://github.com/square/Valet'
Expand Down
38 changes: 18 additions & 20 deletions Valet/VALSecureEnclaveValet.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,15 @@ - (nullable instancetype)initWithIdentifier:(nonnull NSString *)identifier acces

VALAccessibility const accessibility = VALAccessibilityWhenPasscodeSetThisDeviceOnly;
self = [super initWithIdentifier:identifier accessibility:accessibility];
if (self != nil) {
SEL const backwardsCompatibleInitializer = @selector(initWithIdentifier:accessibility:);
NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithIdentifier:identifier
accessibility:accessibility
initializer:backwardsCompatibleInitializer];
[[self class] _augmentBaseQuery:baseQuery
accessControl:accessControl];
_baseQuery = baseQuery;
_accessControl = accessControl;
}

SEL const backwardsCompatibleInitializer = @selector(initWithIdentifier:accessibility:);
NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithIdentifier:identifier
accessibility:accessibility
initializer:backwardsCompatibleInitializer];
[[self class] _augmentBaseQuery:baseQuery
accessControl:accessControl];
_baseQuery = baseQuery;
_accessControl = accessControl;

return [[self class] sharedValetForValet:self];
}
Expand All @@ -221,16 +220,15 @@ - (nullable instancetype)initWithSharedAccessGroupIdentifier:(nonnull NSString *

VALAccessibility const accessibility = VALAccessibilityWhenPasscodeSetThisDeviceOnly;
self = [super initWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier accessibility:accessibility];
if (self != nil) {
SEL const backwardsCompatibleInitializer = @selector(initWithSharedAccessGroupIdentifier:accessibility:);
NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier
accessibility:accessibility
initializer:backwardsCompatibleInitializer];
[[self class] _augmentBaseQuery:baseQuery
accessControl:accessControl];
_baseQuery = baseQuery;
_accessControl = accessControl;
}

SEL const backwardsCompatibleInitializer = @selector(initWithSharedAccessGroupIdentifier:accessibility:);
NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier
accessibility:accessibility
initializer:backwardsCompatibleInitializer];
[[self class] _augmentBaseQuery:baseQuery
accessControl:accessControl];
_baseQuery = baseQuery;
_accessControl = accessControl;

return [[self class] sharedValetForValet:self];
}
Expand Down
26 changes: 12 additions & 14 deletions Valet/VALSynchronizableValet.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ - (nullable instancetype)initWithIdentifier:(nonnull NSString *)identifier acces
VALCheckCondition([[self class] supportsSynchronizableKeychainItems], nil, @"This device does not support synchronizing data to iCloud.");

self = [super initWithIdentifier:identifier accessibility:accessibility];
if (self != nil) {
NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithIdentifier:identifier
accessibility:accessibility
initializer:_cmd];
[[self class] _augmentBaseQuery:baseQuery];
_baseQuery = baseQuery;
}

NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithIdentifier:identifier
accessibility:accessibility
initializer:_cmd];
[[self class] _augmentBaseQuery:baseQuery];
_baseQuery = baseQuery;

return [[self class] sharedValetForValet:self];
}
Expand All @@ -81,13 +80,12 @@ - (nullable instancetype)initWithSharedAccessGroupIdentifier:(nonnull NSString *
VALCheckCondition([[self class] supportsSynchronizableKeychainItems], nil, @"This device does not support synchronizing data to iCloud.");

self = [super initWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier accessibility:accessibility];
if (self != nil) {
NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier
accessibility:accessibility
initializer:_cmd];
[[self class] _augmentBaseQuery:baseQuery];
_baseQuery = baseQuery;
}

NSMutableDictionary *const baseQuery = [[self class] mutableBaseQueryWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier
accessibility:accessibility
initializer:_cmd];
[[self class] _augmentBaseQuery:baseQuery];
_baseQuery = baseQuery;

return [[self class] sharedValetForValet:self];
}
Expand Down
4 changes: 2 additions & 2 deletions Valet/VALValet.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ typedef NS_ENUM(NSUInteger, VALMigrationError) {
/// @see VALAccessibility
- (nullable instancetype)initWithSharedAccessGroupIdentifier:(nonnull NSString *)sharedAccessGroupIdentifier accessibility:(VALAccessibility)accessibility NS_DESIGNATED_INITIALIZER;

- (nullable instancetype)init NS_UNAVAILABLE;
+ (nullable instancetype)new NS_UNAVAILABLE;
- (nonnull instancetype)init NS_UNAVAILABLE;
+ (nonnull instancetype)new NS_UNAVAILABLE;

@property (nonnull, copy, readonly) NSString *identifier;
@property (readonly, getter=isSharedAcrossApplications) BOOL sharedAcrossApplications;
Expand Down
28 changes: 13 additions & 15 deletions Valet/VALValet.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,12 @@ - (nullable instancetype)initWithIdentifier:(nonnull NSString *)identifier acces
VALCheckCondition(accessibility > 0, nil, @"Valet requires a valid accessibility setting");

self = [super init];
if (self != nil) {
_baseQuery = [[self class] mutableBaseQueryWithIdentifier:identifier accessibility:accessibility initializer:_cmd];
_identifier = [identifier copy];
_sharedAcrossApplications = NO;
_accessibility = accessibility;
_lockForSetAndRemoveOperations = [NSLock new];
}

_baseQuery = [[self class] mutableBaseQueryWithIdentifier:identifier accessibility:accessibility initializer:_cmd];
_identifier = [identifier copy];
_sharedAcrossApplications = NO;
_accessibility = accessibility;
_lockForSetAndRemoveOperations = [NSLock new];

return [[self class] sharedValetForValet:self];
}
Expand All @@ -260,14 +259,13 @@ - (nullable instancetype)initWithSharedAccessGroupIdentifier:(nonnull NSString *
VALCheckCondition(accessibility > 0, nil, @"Valet requires a valid accessibility setting");

self = [super init];
if (self != nil) {
_baseQuery = [[self class] mutableBaseQueryWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier accessibility:accessibility initializer:_cmd];

_identifier = [sharedAccessGroupIdentifier copy];
_sharedAcrossApplications = YES;
_accessibility = accessibility;
_lockForSetAndRemoveOperations = [NSLock new];
}

_baseQuery = [[self class] mutableBaseQueryWithSharedAccessGroupIdentifier:sharedAccessGroupIdentifier accessibility:accessibility initializer:_cmd];

_identifier = [sharedAccessGroupIdentifier copy];
_sharedAcrossApplications = YES;
_accessibility = accessibility;
_lockForSetAndRemoveOperations = [NSLock new];

return [[self class] sharedValetForValet:self];
}
Expand Down

0 comments on commit 0a0ae2c

Please sign in to comment.