diff --git a/PasscodeLock.podspec b/PasscodeLock.podspec index f27b3db6..4a0a662a 100755 --- a/PasscodeLock.podspec +++ b/PasscodeLock.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PasscodeLock' -s.version = '1.0.1' +s.version = '1.0.3' s.license = { :type => "MIT", :file => 'LICENSE.txt' } s.summary = 'An iOS passcode lock with Touch ID authentication written in Swift.' s.homepage = 'https://github.com/yankodimitrov/SwiftPasscodeLock' @@ -18,4 +18,4 @@ s.resources = [ ] s.requires_arc = true -end \ No newline at end of file +end diff --git a/PasscodeLock.xcodeproj/project.pbxproj b/PasscodeLock.xcodeproj/project.pbxproj index 0849b504..ee227d8c 100644 --- a/PasscodeLock.xcodeproj/project.pbxproj +++ b/PasscodeLock.xcodeproj/project.pbxproj @@ -8,8 +8,8 @@ /* Begin PBXBuildFile section */ C99EAF431B90B05700D61E1B /* PasscodeLock.h in Headers */ = {isa = PBXBuildFile; fileRef = C99EAF421B90B05700D61E1B /* PasscodeLock.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C99EAF4A1B90B05800D61E1B /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; settings = {ASSET_TAGS = (); }; }; - C9D3DF0B1B919CE4008561EB /* PasscodeLockView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF0A1B919CE4008561EB /* PasscodeLockView.xib */; settings = {ASSET_TAGS = (); }; }; + C99EAF4A1B90B05800D61E1B /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; }; + C9D3DF0B1B919CE4008561EB /* PasscodeLockView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF0A1B919CE4008561EB /* PasscodeLockView.xib */; }; C9D3DF131B91AD11008561EB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF121B91AD11008561EB /* AppDelegate.swift */; }; C9D3DF151B91AD11008561EB /* PasscodeSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF141B91AD11008561EB /* PasscodeSettingsViewController.swift */; }; C9D3DF181B91AD11008561EB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF161B91AD11008561EB /* Main.storyboard */; }; @@ -17,45 +17,45 @@ C9D3DF1D1B91AD11008561EB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C9D3DF1B1B91AD11008561EB /* LaunchScreen.storyboard */; }; C9D3DF3E1B91AD7A008561EB /* PasscodeLock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; }; C9D3DF3F1B91AD7A008561EB /* PasscodeLock.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C99EAF3F1B90B05700D61E1B /* PasscodeLock.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C9D3DF441B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF431B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift */; settings = {ASSET_TAGS = (); }; }; - C9D3DF461B91BD0E008561EB /* PasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF451B91BD0E008561EB /* PasscodeLockConfiguration.swift */; settings = {ASSET_TAGS = (); }; }; - C9D3DF481B91F099008561EB /* PasscodeLockPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF471B91F099008561EB /* PasscodeLockPresenter.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D51B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D61B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D81B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07D91B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DB1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DC1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DE1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07DF1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07E11B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07E21B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07E51B90BCF9007A4DD0 /* PasscodeLockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E41B90BCF9007A4DD0 /* PasscodeLockTests.swift */; settings = {ASSET_TAGS = (); }; }; + C9D3DF441B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF431B91B9CD008561EB /* UserDefaultsPasscodeRepository.swift */; }; + C9D3DF461B91BD0E008561EB /* PasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF451B91BD0E008561EB /* PasscodeLockConfiguration.swift */; }; + C9D3DF481B91F099008561EB /* PasscodeLockPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9D3DF471B91F099008561EB /* PasscodeLockPresenter.swift */; }; + C9DC07D51B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; }; + C9DC07D61B90B1F6007A4DD0 /* PasscodeRepositoryType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D41B90B1F6007A4DD0 /* PasscodeRepositoryType.swift */; }; + C9DC07D81B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; }; + C9DC07D91B90B261007A4DD0 /* PasscodeLockStateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07D71B90B261007A4DD0 /* PasscodeLockStateType.swift */; }; + C9DC07DB1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; }; + C9DC07DC1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DA1B90B730007A4DD0 /* PasscodeLockConfigurationType.swift */; }; + C9DC07DE1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; }; + C9DC07DF1B90BA06007A4DD0 /* PasscodeLockType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07DD1B90BA06007A4DD0 /* PasscodeLockType.swift */; }; + C9DC07E11B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; }; + C9DC07E21B90BBFD007A4DD0 /* PasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E01B90BBFD007A4DD0 /* PasscodeLock.swift */; }; + C9DC07E51B90BCF9007A4DD0 /* PasscodeLockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E41B90BCF9007A4DD0 /* PasscodeLockTests.swift */; }; C9DC07E71B90C382007A4DD0 /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9DC07E61B90C382007A4DD0 /* LocalAuthentication.framework */; }; - C9DC07EA1B90C690007A4DD0 /* FakePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E91B90C690007A4DD0 /* FakePasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07EC1B90C72A007A4DD0 /* FakePasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EB1B90C72A007A4DD0 /* FakePasscodeRepository.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07EE1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07ED1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F01B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EF1B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F21B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F31B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F81B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07F91B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC07FC1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; settings = {ASSET_TAGS = (); }; }; - C9DC07FD1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; settings = {ASSET_TAGS = (); }; }; - C9DC07FF1B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08001B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08021B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08031B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08051B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08061B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08081B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08071B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC080A1B90DB09007A4DD0 /* FakePasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08091B90DB09007A4DD0 /* FakePasscodeLock.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC080C1B90DC38007A4DD0 /* SetPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080B1B90DC38007A4DD0 /* SetPasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC080E1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080D1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08101B90DD91007A4DD0 /* ChangePasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080F1B90DD91007A4DD0 /* ChangePasscodeStateTests.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08121B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08111B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08141B90DE50007A4DD0 /* PasscodeSignButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08131B90DE50007A4DD0 /* PasscodeSignButton.swift */; settings = {ASSET_TAGS = (); }; }; - C9DC08161B90DF4E007A4DD0 /* PasscodeLockViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08151B90DF4E007A4DD0 /* PasscodeLockViewController.swift */; settings = {ASSET_TAGS = (); }; }; + C9DC07EA1B90C690007A4DD0 /* FakePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07E91B90C690007A4DD0 /* FakePasscodeState.swift */; }; + C9DC07EC1B90C72A007A4DD0 /* FakePasscodeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EB1B90C72A007A4DD0 /* FakePasscodeRepository.swift */; }; + C9DC07EE1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07ED1B90C7CD007A4DD0 /* FakePasscodeLockConfiguration.swift */; }; + C9DC07F01B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07EF1B90C8E1007A4DD0 /* FakePasscodeLockDelegate.swift */; }; + C9DC07F21B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; }; + C9DC07F31B90C9DE007A4DD0 /* EnterPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F11B90C9DE007A4DD0 /* EnterPasscodeState.swift */; }; + C9DC07F81B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; }; + C9DC07F91B90CF29007A4DD0 /* Functions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07F71B90CF29007A4DD0 /* Functions.swift */; }; + C9DC07FC1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; }; + C9DC07FD1B90D0A3007A4DD0 /* PasscodeLock.strings in Resources */ = {isa = PBXBuildFile; fileRef = C9DC07FA1B90D0A3007A4DD0 /* PasscodeLock.strings */; }; + C9DC07FF1B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; }; + C9DC08001B90D24A007A4DD0 /* SetPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC07FE1B90D24A007A4DD0 /* SetPasscodeState.swift */; }; + C9DC08021B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; }; + C9DC08031B90D2BA007A4DD0 /* ConfirmPasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08011B90D2BA007A4DD0 /* ConfirmPasscodeState.swift */; }; + C9DC08051B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; }; + C9DC08061B90D394007A4DD0 /* ChangePasscodeState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08041B90D394007A4DD0 /* ChangePasscodeState.swift */; }; + C9DC08081B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08071B90DAE6007A4DD0 /* EnterPasscodeStateTests.swift */; }; + C9DC080A1B90DB09007A4DD0 /* FakePasscodeLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08091B90DB09007A4DD0 /* FakePasscodeLock.swift */; }; + C9DC080C1B90DC38007A4DD0 /* SetPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080B1B90DC38007A4DD0 /* SetPasscodeStateTests.swift */; }; + C9DC080E1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080D1B90DC8F007A4DD0 /* ConfirmPasscodeStateTests.swift */; }; + C9DC08101B90DD91007A4DD0 /* ChangePasscodeStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC080F1B90DD91007A4DD0 /* ChangePasscodeStateTests.swift */; }; + C9DC08121B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08111B90DE1B007A4DD0 /* PasscodeSignPlaceholderView.swift */; }; + C9DC08141B90DE50007A4DD0 /* PasscodeSignButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08131B90DE50007A4DD0 /* PasscodeSignButton.swift */; }; + C9DC08161B90DF4E007A4DD0 /* PasscodeLockViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9DC08151B90DF4E007A4DD0 /* PasscodeLockViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -446,24 +446,28 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0910; ORGANIZATIONNAME = "Yanko Dimitrov"; TargetAttributes = { C99EAF3E1B90B05700D61E1B = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 0910; }; C99EAF481B90B05700D61E1B = { CreatedOnToolsVersion = 7.0; }; C9D3DF0F1B91AD11008561EB = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 0910; }; C9D3DF221B91AD11008561EB = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 0800; TestTargetID = C9D3DF0F1B91AD11008561EB; }; C9D3DF2D1B91AD12008561EB = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 0800; TestTargetID = C9D3DF0F1B91AD11008561EB; }; }; @@ -669,13 +673,21 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -717,13 +729,21 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -743,6 +763,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -754,6 +775,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -765,6 +787,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -772,6 +796,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -782,6 +807,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLock; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -813,13 +840,15 @@ C9D3DF361B91AD12008561EB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; INFOPLIST_FILE = PasscodeLockDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLockDemo; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -827,13 +856,15 @@ C9D3DF371B91AD12008561EB /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; INFOPLIST_FILE = PasscodeLockDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLockDemo; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -847,6 +878,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLockDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PasscodeLockDemo.app/PasscodeLockDemo"; }; name = Debug; @@ -860,6 +892,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLockDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PasscodeLockDemo.app/PasscodeLockDemo"; }; name = Release; @@ -872,6 +905,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLockDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_TARGET_NAME = PasscodeLockDemo; USES_XCTRUNNER = YES; }; @@ -885,6 +919,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.yankodimitrov.PasscodeLockDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_TARGET_NAME = PasscodeLockDemo; USES_XCTRUNNER = YES; }; diff --git a/PasscodeLock.xcodeproj/xcshareddata/xcschemes/PasscodeLock.xcscheme b/PasscodeLock.xcodeproj/xcshareddata/xcschemes/PasscodeLock.xcscheme index a4bdf8ec..6a223ae4 100644 --- a/PasscodeLock.xcodeproj/xcshareddata/xcschemes/PasscodeLock.xcscheme +++ b/PasscodeLock.xcodeproj/xcshareddata/xcschemes/PasscodeLock.xcscheme @@ -1,6 +1,6 @@ String { +func localizedStringFor(_ key: String, comment: String) -> String { let name = "PasscodeLock" let bundle = bundleForResource(name, ofType: "strings") @@ -16,11 +16,11 @@ func localizedStringFor(key: String, comment: String) -> String { return NSLocalizedString(key, tableName: name, bundle: bundle, comment: comment) } -func bundleForResource(name: String, ofType type: String) -> NSBundle { +func bundleForResource(_ name: String, ofType type: String) -> Bundle { - if(NSBundle.mainBundle().pathForResource(name, ofType: type) != nil) { - return NSBundle.mainBundle() + if(Bundle.main.path(forResource: name, ofType: type) != nil) { + return Bundle.main } - return NSBundle(forClass: PasscodeLock.self) + return Bundle(for: PasscodeLock.self) } diff --git a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift index 1106f145..aefaacae 100644 --- a/PasscodeLock/PasscodeLock/ChangePasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ChangePasscodeState.swift @@ -21,7 +21,7 @@ struct ChangePasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockChangeDescription", comment: "Change passcode description") } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { guard let currentPasscode = lock.repository.passcode else { return diff --git a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift index c6683cea..371562b5 100644 --- a/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/ConfirmPasscodeState.swift @@ -15,7 +15,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { let isCancellableAction = true var isTouchIDAllowed = false - private var passcodeToConfirm: [String] + fileprivate var passcodeToConfirm: [String] init(passcode: [String]) { @@ -24,7 +24,7 @@ struct ConfirmPasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockConfirmDescription", comment: "Confirm passcode description") } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { if passcode == passcodeToConfirm { diff --git a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift index 60f58bc8..6716e0cd 100644 --- a/PasscodeLock/PasscodeLock/EnterPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/EnterPasscodeState.swift @@ -17,8 +17,8 @@ struct EnterPasscodeState: PasscodeLockStateType { let isCancellableAction: Bool var isTouchIDAllowed = true - private var inccorectPasscodeAttempts = 0 - private var isNotificationSent = false + fileprivate var inccorectPasscodeAttempts = 0 + fileprivate var isNotificationSent = false init(allowCancellation: Bool = false) { @@ -27,7 +27,7 @@ struct EnterPasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockEnterDescription", comment: "Enter passcode description") } - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + mutating func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { guard let currentPasscode = lock.repository.passcode else { return @@ -50,13 +50,13 @@ struct EnterPasscodeState: PasscodeLockStateType { } } - private mutating func postNotification() { + fileprivate mutating func postNotification() { guard !isNotificationSent else { return } - let center = NSNotificationCenter.defaultCenter() + let center = NotificationCenter.default - center.postNotificationName(PasscodeLockIncorrectPasscodeNotification, object: nil) + center.post(name: Notification.Name(rawValue: PasscodeLockIncorrectPasscodeNotification), object: nil) isNotificationSent = true } diff --git a/PasscodeLock/PasscodeLock/PasscodeLock.swift b/PasscodeLock/PasscodeLock/PasscodeLock.swift index a6ca8372..dc5698f5 100644 --- a/PasscodeLock/PasscodeLock/PasscodeLock.swift +++ b/PasscodeLock/PasscodeLock/PasscodeLock.swift @@ -9,25 +9,25 @@ import Foundation import LocalAuthentication -public class PasscodeLock: PasscodeLockType { +open class PasscodeLock: PasscodeLockType { - public weak var delegate: PasscodeLockTypeDelegate? - public let configuration: PasscodeLockConfigurationType + open weak var delegate: PasscodeLockTypeDelegate? + open let configuration: PasscodeLockConfigurationType - public var repository: PasscodeRepositoryType { + open var repository: PasscodeRepositoryType { return configuration.repository } - public var state: PasscodeLockStateType { + open var state: PasscodeLockStateType { return lockState } - public var isTouchIDAllowed: Bool { + open var isTouchIDAllowed: Bool { return isTouchIDEnabled() && configuration.isTouchIDAllowed && lockState.isTouchIDAllowed } - private var lockState: PasscodeLockStateType - private lazy var passcode = [String]() + fileprivate var lockState: PasscodeLockStateType + fileprivate lazy var passcode = [String]() public init(state: PasscodeLockStateType, configuration: PasscodeLockConfigurationType) { @@ -37,7 +37,7 @@ public class PasscodeLock: PasscodeLockType { self.configuration = configuration } - public func addSign(sign: String) { + open func addSign(_ sign: String) { passcode.append(sign) delegate?.passcodeLock(self, addedSignAtIndex: passcode.count - 1) @@ -45,11 +45,11 @@ public class PasscodeLock: PasscodeLockType { if passcode.count >= configuration.passcodeLength { lockState.acceptPasscode(passcode, fromLock: self) - passcode.removeAll(keepCapacity: true) + passcode.removeAll(keepingCapacity: true) } } - public func removeSign() { + open func removeSign() { guard passcode.count > 0 else { return } @@ -57,13 +57,13 @@ public class PasscodeLock: PasscodeLockType { delegate?.passcodeLock(self, removedSignAtIndex: passcode.count) } - public func changeStateTo(state: PasscodeLockStateType) { + open func changeStateTo(_ state: PasscodeLockStateType) { lockState = state delegate?.passcodeLockDidChangeState(self) } - public func authenticateWithBiometrics() { + open func authenticateWithBiometrics() { guard isTouchIDAllowed else { return } @@ -72,16 +72,16 @@ public class PasscodeLock: PasscodeLockType { context.localizedFallbackTitle = localizedStringFor("PasscodeLockTouchIDButton", comment: "TouchID authentication fallback button") - context.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { + context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, error in self.handleTouchIDResult(success) } } - private func handleTouchIDResult(success: Bool) { + fileprivate func handleTouchIDResult(_ success: Bool) { - dispatch_async(dispatch_get_main_queue()) { + DispatchQueue.main.async { if success { @@ -90,10 +90,10 @@ public class PasscodeLock: PasscodeLockType { } } - private func isTouchIDEnabled() -> Bool { + fileprivate func isTouchIDEnabled() -> Bool { let context = LAContext() - return context.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil) + return context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: nil) } } diff --git a/PasscodeLock/PasscodeLock/SetPasscodeState.swift b/PasscodeLock/PasscodeLock/SetPasscodeState.swift index f4a96be9..b43e4bbb 100644 --- a/PasscodeLock/PasscodeLock/SetPasscodeState.swift +++ b/PasscodeLock/PasscodeLock/SetPasscodeState.swift @@ -27,7 +27,7 @@ struct SetPasscodeState: PasscodeLockStateType { description = localizedStringFor("PasscodeLockSetDescription", comment: "Set passcode description") } - func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) { + func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) { let nextState = ConfirmPasscodeState(passcode: passcode) diff --git a/PasscodeLock/PasscodeLockPresenter.swift b/PasscodeLock/PasscodeLockPresenter.swift index c2ac3d6d..611cc4a2 100644 --- a/PasscodeLock/PasscodeLockPresenter.swift +++ b/PasscodeLock/PasscodeLockPresenter.swift @@ -8,13 +8,13 @@ import UIKit -public class PasscodeLockPresenter { +open class PasscodeLockPresenter { - private var mainWindow: UIWindow? + fileprivate var mainWindow: UIWindow? - private lazy var passcodeLockWindow: UIWindow = { + fileprivate lazy var passcodeLockWindow: UIWindow = { - let window = UIWindow(frame: UIScreen.mainScreen().bounds) + let window = UIWindow(frame: UIScreen.main.bounds) window.windowLevel = 0 window.makeKeyAndVisible() @@ -22,9 +22,9 @@ public class PasscodeLockPresenter { return window }() - private let passcodeConfiguration: PasscodeLockConfigurationType - public var isPasscodePresented = false - public let passcodeLockVC: PasscodeLockViewController + fileprivate let passcodeConfiguration: PasscodeLockConfigurationType + open var isPasscodePresented = false + open let passcodeLockVC: PasscodeLockViewController public init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, viewController: PasscodeLockViewController) { @@ -37,12 +37,12 @@ public class PasscodeLockPresenter { public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType) { - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration) + let passcodeLockVC = PasscodeLockViewController(state: .enterPasscode, configuration: configuration) self.init(mainWindow: window, configuration: configuration, viewController: passcodeLockVC) } - public func presentPasscodeLock() { + open func presentPasscodeLock() { guard passcodeConfiguration.repository.hasPasscode else { return } guard !isPasscodePresented else { return } @@ -50,12 +50,12 @@ public class PasscodeLockPresenter { isPasscodePresented = true passcodeLockWindow.windowLevel = 2 - passcodeLockWindow.hidden = false + passcodeLockWindow.isHidden = false mainWindow?.windowLevel = 1 mainWindow?.endEditing(true) - let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: passcodeConfiguration) + let passcodeLockVC = PasscodeLockViewController(state: .enterPasscode, configuration: passcodeConfiguration) let userDismissCompletionCallback = passcodeLockVC.dismissCompletionCallback passcodeLockVC.dismissCompletionCallback = { [weak self] in @@ -68,7 +68,7 @@ public class PasscodeLockPresenter { passcodeLockWindow.rootViewController = passcodeLockVC } - public func dismissPasscodeLock(animated animated: Bool = true) { + open func dismissPasscodeLock(animated: Bool = true) { isPasscodePresented = false mainWindow?.windowLevel = 1 @@ -87,12 +87,12 @@ public class PasscodeLockPresenter { internal func animatePasscodeLockDismissal() { - UIView.animateWithDuration( - 0.5, + UIView.animate( + withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, - options: [.CurveEaseInOut], + options: UIViewAnimationOptions(), animations: { [weak self] in self?.passcodeLockWindow.alpha = 0 diff --git a/PasscodeLock/PasscodeLockViewController.swift b/PasscodeLock/PasscodeLockViewController.swift index 095f10f2..ccf1d3e8 100644 --- a/PasscodeLock/PasscodeLockViewController.swift +++ b/PasscodeLock/PasscodeLockViewController.swift @@ -8,43 +8,43 @@ import UIKit -public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegate { +open class PasscodeLockViewController: UIViewController, PasscodeLockTypeDelegate { public enum LockState { - case EnterPasscode - case SetPasscode - case ChangePasscode - case RemovePasscode + case enterPasscode + case setPasscode + case changePasscode + case removePasscode func getState() -> PasscodeLockStateType { switch self { - case .EnterPasscode: return EnterPasscodeState() - case .SetPasscode: return SetPasscodeState() - case .ChangePasscode: return ChangePasscodeState() - case .RemovePasscode: return EnterPasscodeState(allowCancellation: true) + case .enterPasscode: return EnterPasscodeState() + case .setPasscode: return SetPasscodeState() + case .changePasscode: return ChangePasscodeState() + case .removePasscode: return EnterPasscodeState(allowCancellation: true) } } } - @IBOutlet public weak var titleLabel: UILabel? - @IBOutlet public weak var descriptionLabel: UILabel? - @IBOutlet public var placeholders: [PasscodeSignPlaceholderView] = [PasscodeSignPlaceholderView]() - @IBOutlet public weak var cancelButton: UIButton? - @IBOutlet public weak var deleteSignButton: UIButton? - @IBOutlet public weak var touchIDButton: UIButton? - @IBOutlet public weak var placeholdersX: NSLayoutConstraint? + @IBOutlet open weak var titleLabel: UILabel? + @IBOutlet open weak var descriptionLabel: UILabel? + @IBOutlet open var placeholders: [PasscodeSignPlaceholderView] = [PasscodeSignPlaceholderView]() + @IBOutlet open weak var cancelButton: UIButton? + @IBOutlet open weak var deleteSignButton: UIButton? + @IBOutlet open weak var touchIDButton: UIButton? + @IBOutlet open weak var placeholdersX: NSLayoutConstraint? - public var successCallback: ((lock: PasscodeLockType) -> Void)? - public var dismissCompletionCallback: (()->Void)? - public var animateOnDismiss: Bool - public var notificationCenter: NSNotificationCenter? + open var successCallback: ((_ lock: PasscodeLockType) -> Void)? + open var dismissCompletionCallback: (()->Void)? + open var animateOnDismiss: Bool + open var notificationCenter: NotificationCenter? internal let passcodeConfiguration: PasscodeLockConfigurationType - internal let passcodeLock: PasscodeLockType + internal var passcodeLock: PasscodeLockType internal var isPlaceholdersAnimationCompleted = true - private var shouldTryToAuthenticateWithBiometrics = true + fileprivate var shouldTryToAuthenticateWithBiometrics = true // MARK: - Initializers @@ -56,12 +56,12 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg passcodeLock = PasscodeLock(state: state, configuration: configuration) let nibName = "PasscodeLockView" - let bundle: NSBundle = bundleForResource(nibName, ofType: "nib") + let bundle: Bundle = bundleForResource(nibName, ofType: "nib") super.init(nibName: nibName, bundle: bundle) passcodeLock.delegate = self - notificationCenter = NSNotificationCenter.defaultCenter() + notificationCenter = NotificationCenter.default } public convenience init(state: LockState, configuration: PasscodeLockConfigurationType, animateOnDismiss: Bool = true) { @@ -80,16 +80,16 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg // MARK: - View - public override func viewDidLoad() { + open override func viewDidLoad() { super.viewDidLoad() updatePasscodeView() - deleteSignButton?.enabled = false + deleteSignButton?.isEnabled = false setupEvents() } - public override func viewDidAppear(animated: Bool) { + open override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) if shouldTryToAuthenticateWithBiometrics { @@ -102,59 +102,61 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg titleLabel?.text = passcodeLock.state.title descriptionLabel?.text = passcodeLock.state.description - cancelButton?.hidden = !passcodeLock.state.isCancellableAction - touchIDButton?.hidden = !passcodeLock.isTouchIDAllowed + + cancelButton?.isHidden = !passcodeLock.state.isCancellableAction + touchIDButton?.isHidden = !passcodeLock.isTouchIDAllowed + cancelButton?.setTitle(localizedStringFor("PasscodeLockCancelButton", comment: "Cancel"), for: .normal) + deleteSignButton?.setTitle(localizedStringFor("PasscodeLockDeleteButton", comment: "Delete"), for: .normal) } // MARK: - Events - private func setupEvents() { - - notificationCenter?.addObserver(self, selector: "appWillEnterForegroundHandler:", name: UIApplicationWillEnterForegroundNotification, object: nil) - notificationCenter?.addObserver(self, selector: "appDidEnterBackgroundHandler:", name: UIApplicationDidEnterBackgroundNotification, object: nil) + fileprivate func setupEvents() { + notificationCenter?.addObserver(self, selector: #selector(PasscodeLockViewController.appWillEnterForegroundHandler(_:)), name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil) + notificationCenter?.addObserver(self, selector: #selector(PasscodeLockViewController.appDidEnterBackgroundHandler(_:)), name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil) } - private func clearEvents() { + fileprivate func clearEvents() { - notificationCenter?.removeObserver(self, name: UIApplicationWillEnterForegroundNotification, object: nil) - notificationCenter?.removeObserver(self, name: UIApplicationDidEnterBackgroundNotification, object: nil) + notificationCenter?.removeObserver(self, name: NSNotification.Name.UIApplicationWillEnterForeground, object: nil) + notificationCenter?.removeObserver(self, name: NSNotification.Name.UIApplicationDidEnterBackground, object: nil) } - public func appWillEnterForegroundHandler(notification: NSNotification) { - + @objc open func appWillEnterForegroundHandler(_ notification: Notification) { + authenticateWithBiometrics() } - public func appDidEnterBackgroundHandler(notification: NSNotification) { + @objc open func appDidEnterBackgroundHandler(_ notification: Notification) { shouldTryToAuthenticateWithBiometrics = false } // MARK: - Actions - @IBAction func passcodeSignButtonTap(sender: PasscodeSignButton) { + @IBAction func passcodeSignButtonTap(_ sender: PasscodeSignButton) { guard isPlaceholdersAnimationCompleted else { return } passcodeLock.addSign(sender.passcodeSign) } - @IBAction func cancelButtonTap(sender: UIButton) { + @IBAction func cancelButtonTap(_ sender: UIButton) { dismissPasscodeLock(passcodeLock) } - @IBAction func deleteSignButtonTap(sender: UIButton) { + @IBAction func deleteSignButtonTap(_ sender: UIButton) { passcodeLock.removeSign() } - @IBAction func touchIDButtonTap(sender: UIButton) { + @IBAction func touchIDButtonTap(_ sender: UIButton) { passcodeLock.authenticateWithBiometrics() } - private func authenticateWithBiometrics() { + fileprivate func authenticateWithBiometrics() { if passcodeConfiguration.shouldRequestTouchIDImmediately && passcodeLock.isTouchIDAllowed { @@ -162,12 +164,12 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg } } - internal func dismissPasscodeLock(lock: PasscodeLockType, completionHandler: (() -> Void)? = nil) { + internal func dismissPasscodeLock(_ lock: PasscodeLockType, completionHandler: (() -> Void)? = nil) { // if presented as modal if presentingViewController?.presentedViewController == self { - - dismissViewControllerAnimated(animateOnDismiss, completion: { [weak self] _ in + + dismiss(animated: animateOnDismiss, completion: { [weak self] in self?.dismissCompletionCallback?() @@ -177,9 +179,9 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg return // if pushed in a navigation controller - } else if navigationController != nil { + } else if let navigationController = navigationController { - navigationController?.popViewControllerAnimated(animateOnDismiss) + navigationController.popViewController(animated: animateOnDismiss) } dismissCompletionCallback?() @@ -191,16 +193,16 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg internal func animateWrongPassword() { - deleteSignButton?.enabled = false + deleteSignButton?.isEnabled = false isPlaceholdersAnimationCompleted = false - animatePlaceholders(placeholders, toState: .Error) + animatePlaceholders(placeholders, toState: .error) placeholdersX?.constant = -40 view.layoutIfNeeded() - UIView.animateWithDuration( - 0.5, + UIView.animate( + withDuration: 0.5, delay: 0, usingSpringWithDamping: 0.2, initialSpringVelocity: 0, @@ -213,11 +215,11 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg completion: { completed in self.isPlaceholdersAnimationCompleted = true - self.animatePlaceholders(self.placeholders, toState: .Inactive) + self.animatePlaceholders(self.placeholders, toState: .inactive) }) } - internal func animatePlaceholders(placeholders: [PasscodeSignPlaceholderView], toState state: PasscodeSignPlaceholderView.State) { + internal func animatePlaceholders(_ placeholders: [PasscodeSignPlaceholderView], toState state: PasscodeSignPlaceholderView.State) { for placeholder in placeholders { @@ -225,7 +227,7 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg } } - private func animatePlacehodlerAtIndex(index: Int, toState state: PasscodeSignPlaceholderView.State) { + fileprivate func animatePlacehodlerAtIndex(_ index: Int, toState state: PasscodeSignPlaceholderView.State) { guard index < placeholders.count && index >= 0 else { return } @@ -234,40 +236,40 @@ public class PasscodeLockViewController: UIViewController, PasscodeLockTypeDeleg // MARK: - PasscodeLockDelegate - public func passcodeLockDidSucceed(lock: PasscodeLockType) { + open func passcodeLockDidSucceed(_ lock: PasscodeLockType) { - deleteSignButton?.enabled = true - animatePlaceholders(placeholders, toState: .Inactive) - dismissPasscodeLock(lock, completionHandler: { [weak self] _ in - self?.successCallback?(lock: lock) + deleteSignButton?.isEnabled = true + animatePlaceholders(placeholders, toState: .inactive) + dismissPasscodeLock(lock, completionHandler: { [weak self] in + self?.successCallback?(lock) }) } - public func passcodeLockDidFail(lock: PasscodeLockType) { + open func passcodeLockDidFail(_ lock: PasscodeLockType) { animateWrongPassword() } - public func passcodeLockDidChangeState(lock: PasscodeLockType) { + open func passcodeLockDidChangeState(_ lock: PasscodeLockType) { updatePasscodeView() - animatePlaceholders(placeholders, toState: .Inactive) - deleteSignButton?.enabled = false + animatePlaceholders(placeholders, toState: .inactive) + deleteSignButton?.isEnabled = false } - public func passcodeLock(lock: PasscodeLockType, addedSignAtIndex index: Int) { + open func passcodeLock(_ lock: PasscodeLockType, addedSignAtIndex index: Int) { - animatePlacehodlerAtIndex(index, toState: .Active) - deleteSignButton?.enabled = true + animatePlacehodlerAtIndex(index, toState: .active) + deleteSignButton?.isEnabled = true } - public func passcodeLock(lock: PasscodeLockType, removedSignAtIndex index: Int) { + open func passcodeLock(_ lock: PasscodeLockType, removedSignAtIndex index: Int) { - animatePlacehodlerAtIndex(index, toState: .Inactive) + animatePlacehodlerAtIndex(index, toState: .inactive) if index == 0 { - deleteSignButton?.enabled = false + deleteSignButton?.isEnabled = false } } } diff --git a/PasscodeLock/Protocols/PasscodeLockStateType.swift b/PasscodeLock/Protocols/PasscodeLockStateType.swift index d9725f15..f246e2d9 100644 --- a/PasscodeLock/Protocols/PasscodeLockStateType.swift +++ b/PasscodeLock/Protocols/PasscodeLockStateType.swift @@ -15,5 +15,5 @@ public protocol PasscodeLockStateType { var isCancellableAction: Bool {get} var isTouchIDAllowed: Bool {get} - mutating func acceptPasscode(passcode: [String], fromLock lock: PasscodeLockType) + mutating func acceptPasscode(_ passcode: [String], fromLock lock: PasscodeLockType) } diff --git a/PasscodeLock/Protocols/PasscodeLockType.swift b/PasscodeLock/Protocols/PasscodeLockType.swift index e236b05c..434c87d6 100644 --- a/PasscodeLock/Protocols/PasscodeLockType.swift +++ b/PasscodeLock/Protocols/PasscodeLockType.swift @@ -16,17 +16,17 @@ public protocol PasscodeLockType { var state: PasscodeLockStateType {get} var isTouchIDAllowed: Bool {get} - func addSign(sign: String) + func addSign(_ sign: String) func removeSign() - func changeStateTo(state: PasscodeLockStateType) + func changeStateTo(_ state: PasscodeLockStateType) func authenticateWithBiometrics() } public protocol PasscodeLockTypeDelegate: class { - func passcodeLockDidSucceed(lock: PasscodeLockType) - func passcodeLockDidFail(lock: PasscodeLockType) - func passcodeLockDidChangeState(lock: PasscodeLockType) - func passcodeLock(lock: PasscodeLockType, addedSignAtIndex index: Int) - func passcodeLock(lock: PasscodeLockType, removedSignAtIndex index: Int) + func passcodeLockDidSucceed(_ lock: PasscodeLockType) + func passcodeLockDidFail(_ lock: PasscodeLockType) + func passcodeLockDidChangeState(_ lock: PasscodeLockType) + func passcodeLock(_ lock: PasscodeLockType, addedSignAtIndex index: Int) + func passcodeLock(_ lock: PasscodeLockType, removedSignAtIndex index: Int) } diff --git a/PasscodeLock/Protocols/PasscodeRepositoryType.swift b/PasscodeLock/Protocols/PasscodeRepositoryType.swift index 19272379..79475434 100644 --- a/PasscodeLock/Protocols/PasscodeRepositoryType.swift +++ b/PasscodeLock/Protocols/PasscodeRepositoryType.swift @@ -13,6 +13,6 @@ public protocol PasscodeRepositoryType { var hasPasscode: Bool {get} var passcode: [String]? {get} - func savePasscode(passcode: [String]) + func savePasscode(_ passcode: [String]) func deletePasscode() } diff --git a/PasscodeLock/Views/PasscodeLockView.xib b/PasscodeLock/Views/PasscodeLockView.xib index 99620adb..83cdb135 100644 --- a/PasscodeLock/Views/PasscodeLockView.xib +++ b/PasscodeLock/Views/PasscodeLockView.xib @@ -1,8 +1,10 @@ - - + + - + + + @@ -10,439 +12,483 @@ - + - - - - + + + + - + - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + - - - - - - + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - + - + diff --git a/PasscodeLock/Views/PasscodeSignButton.swift b/PasscodeLock/Views/PasscodeSignButton.swift index 9fb3968a..b04e7f43 100644 --- a/PasscodeLock/Views/PasscodeSignButton.swift +++ b/PasscodeLock/Views/PasscodeSignButton.swift @@ -8,28 +8,27 @@ import UIKit -@IBDesignable -public class PasscodeSignButton: UIButton { - +open class PasscodeSignButton: UIButton { + @IBInspectable - public var passcodeSign: String = "1" + open var passcodeSign: String = "1" @IBInspectable - public var borderColor: UIColor = UIColor.whiteColor() { + open var borderColor: UIColor = UIColor.white { didSet { setupView() } } @IBInspectable - public var borderRadius: CGFloat = 30 { + open var borderRadius: CGFloat = 35 { didSet { setupView() } } @IBInspectable - public var highlightBackgroundColor: UIColor = UIColor.clearColor() { + open var highlightBackgroundColor: UIColor = UIColor.clear { didSet { setupView() } @@ -50,18 +49,18 @@ public class PasscodeSignButton: UIButton { setupActions() } - public override func intrinsicContentSize() -> CGSize { - - return CGSizeMake(60, 60) + open override var intrinsicContentSize: CGSize { + + return CGSize(width: 70, height: 70) } - private var defaultBackgroundColor = UIColor.clearColor() + fileprivate var defaultBackgroundColor = UIColor.clear - private func setupView() { + fileprivate func setupView() { layer.borderWidth = 1 layer.cornerRadius = borderRadius - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor if let backgroundColor = backgroundColor { @@ -69,30 +68,30 @@ public class PasscodeSignButton: UIButton { } } - private func setupActions() { + fileprivate func setupActions() { - addTarget(self, action: Selector("handleTouchDown"), forControlEvents: .TouchDown) - addTarget(self, action: Selector("handleTouchUp"), forControlEvents: [.TouchUpInside, .TouchDragOutside, .TouchCancel]) + addTarget(self, action: #selector(PasscodeSignButton.handleTouchDown), for: .touchDown) + addTarget(self, action: #selector(PasscodeSignButton.handleTouchUp), for: [.touchUpInside, .touchDragOutside, .touchCancel]) } - func handleTouchDown() { + @objc func handleTouchDown() { animateBackgroundColor(highlightBackgroundColor) } - func handleTouchUp() { + @objc func handleTouchUp() { animateBackgroundColor(defaultBackgroundColor) } - private func animateBackgroundColor(color: UIColor) { + fileprivate func animateBackgroundColor(_ color: UIColor) { - UIView.animateWithDuration( - 0.3, + UIView.animate( + withDuration: 0.3, delay: 0.0, usingSpringWithDamping: 1, initialSpringVelocity: 0.0, - options: [.AllowUserInteraction, .BeginFromCurrentState], + options: [.allowUserInteraction, .beginFromCurrentState], animations: { self.backgroundColor = color diff --git a/PasscodeLock/Views/PasscodeSignPlaceholderView.swift b/PasscodeLock/Views/PasscodeSignPlaceholderView.swift index 953c9ef4..48a93799 100644 --- a/PasscodeLock/Views/PasscodeSignPlaceholderView.swift +++ b/PasscodeLock/Views/PasscodeSignPlaceholderView.swift @@ -8,31 +8,30 @@ import UIKit -@IBDesignable -public class PasscodeSignPlaceholderView: UIView { - +open class PasscodeSignPlaceholderView: UIView { + public enum State { - case Inactive - case Active - case Error + case inactive + case active + case error } @IBInspectable - public var inactiveColor: UIColor = UIColor.whiteColor() { + open var inactiveColor: UIColor = UIColor.white { didSet { setupView() } } @IBInspectable - public var activeColor: UIColor = UIColor.grayColor() { + open var activeColor: UIColor = UIColor.gray { didSet { setupView() } } @IBInspectable - public var errorColor: UIColor = UIColor.redColor() { + open var errorColor: UIColor = UIColor.red { didSet { setupView() } @@ -49,35 +48,35 @@ public class PasscodeSignPlaceholderView: UIView { super.init(coder: aDecoder) } - - public override func intrinsicContentSize() -> CGSize { + + open override var intrinsicContentSize: CGSize { - return CGSizeMake(16, 16) + return CGSize(width: 16, height: 16) } - private func setupView() { + fileprivate func setupView() { layer.cornerRadius = 8 layer.borderWidth = 1 - layer.borderColor = activeColor.CGColor + layer.borderColor = activeColor.cgColor backgroundColor = inactiveColor } - private func colorsForState(state: State) -> (backgroundColor: UIColor, borderColor: UIColor) { + fileprivate func colorsForState(_ state: State) -> (backgroundColor: UIColor, borderColor: UIColor) { switch state { - case .Inactive: return (inactiveColor, activeColor) - case .Active: return (activeColor, activeColor) - case .Error: return (errorColor, errorColor) + case .inactive: return (inactiveColor, activeColor) + case .active: return (activeColor, activeColor) + case .error: return (errorColor, errorColor) } } - public func animateState(state: State) { + open func animateState(_ state: State) { let colors = colorsForState(state) - UIView.animateWithDuration( - 0.5, + UIView.animate( + withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, @@ -85,7 +84,7 @@ public class PasscodeSignPlaceholderView: UIView { animations: { self.backgroundColor = colors.backgroundColor - self.layer.borderColor = colors.borderColor.CGColor + self.layer.borderColor = colors.borderColor.cgColor }, completion: nil diff --git a/PasscodeLock/en.lproj/PasscodeLock.strings b/PasscodeLock/en.lproj/PasscodeLock.strings index f71ef86c..a5992a12 100755 --- a/PasscodeLock/en.lproj/PasscodeLock.strings +++ b/PasscodeLock/en.lproj/PasscodeLock.strings @@ -30,4 +30,10 @@ "PasscodeLockTouchIDReason" = "Authentication required to proceed"; /* Touch ID Fallback Button */ -"PasscodeLockTouchIDButton" = "Enter Passcode"; \ No newline at end of file +"PasscodeLockTouchIDButton" = "Enter Passcode"; + +/* Cancel button */ +"PasscodeLockCancelButton" = "Cancel"; + +/* Delete button */ +"PasscodeLockDeleteButton" = "Delete"; diff --git a/PasscodeLockDemo/AppDelegate.swift b/PasscodeLockDemo/AppDelegate.swift index 2646f914..5e6c08c5 100644 --- a/PasscodeLockDemo/AppDelegate.swift +++ b/PasscodeLockDemo/AppDelegate.swift @@ -22,34 +22,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return presenter }() - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { passcodeLockPresenter.presentPasscodeLock() return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. passcodeLockPresenter.presentPasscodeLock() } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } } diff --git a/PasscodeLockDemo/PasscodeSettingsViewController.swift b/PasscodeLockDemo/PasscodeSettingsViewController.swift index 36ac6123..7eafbdff 100644 --- a/PasscodeLockDemo/PasscodeSettingsViewController.swift +++ b/PasscodeLockDemo/PasscodeSettingsViewController.swift @@ -16,7 +16,7 @@ class PasscodeSettingsViewController: UIViewController { @IBOutlet weak var testTextField: UITextField! @IBOutlet weak var testActivityButton: UIButton! - private let configuration: PasscodeLockConfigurationType + fileprivate let configuration: PasscodeLockConfigurationType init(configuration: PasscodeLockConfigurationType) { @@ -35,7 +35,7 @@ class PasscodeSettingsViewController: UIViewController { // MARK: - View - override func viewWillAppear(animated: Bool) { + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) updatePasscodeView() @@ -45,23 +45,23 @@ class PasscodeSettingsViewController: UIViewController { let hasPasscode = configuration.repository.hasPasscode - changePasscodeButton.hidden = !hasPasscode - passcodeSwitch.on = hasPasscode + changePasscodeButton.isHidden = !hasPasscode + passcodeSwitch.isOn = hasPasscode } // MARK: - Actions - @IBAction func passcodeSwitchValueChange(sender: UISwitch) { + @IBAction func passcodeSwitchValueChange(_ sender: UISwitch) { let passcodeVC: PasscodeLockViewController - if passcodeSwitch.on { + if passcodeSwitch.isOn { - passcodeVC = PasscodeLockViewController(state: .SetPasscode, configuration: configuration) + passcodeVC = PasscodeLockViewController(state: .setPasscode, configuration: configuration) } else { - passcodeVC = PasscodeLockViewController(state: .RemovePasscode, configuration: configuration) + passcodeVC = PasscodeLockViewController(state: .removePasscode, configuration: configuration) passcodeVC.successCallback = { lock in @@ -69,37 +69,37 @@ class PasscodeSettingsViewController: UIViewController { } } - presentViewController(passcodeVC, animated: true, completion: nil) + present(passcodeVC, animated: true, completion: nil) } - @IBAction func changePasscodeButtonTap(sender: UIButton) { + @IBAction func changePasscodeButtonTap(_ sender: UIButton) { let repo = UserDefaultsPasscodeRepository() let config = PasscodeLockConfiguration(repository: repo) - let passcodeLock = PasscodeLockViewController(state: .ChangePasscode, configuration: config) + let passcodeLock = PasscodeLockViewController(state: .changePasscode, configuration: config) - presentViewController(passcodeLock, animated: true, completion: nil) + present(passcodeLock, animated: true, completion: nil) } - @IBAction func testAlertButtonTap(sender: UIButton) { + @IBAction func testAlertButtonTap(_ sender: UIButton) { - let alertVC = UIAlertController(title: "Test", message: "", preferredStyle: .Alert) + let alertVC = UIAlertController(title: "Test", message: "", preferredStyle: .alert) - alertVC.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: nil)) + alertVC.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil)) - presentViewController(alertVC, animated: true, completion: nil) + present(alertVC, animated: true, completion: nil) } - @IBAction func testActivityButtonTap(sender: UIButton) { + @IBAction func testActivityButtonTap(_ sender: UIButton) { let activityVC = UIActivityViewController(activityItems: ["Test"], applicationActivities: nil) activityVC.popoverPresentationController?.sourceView = testActivityButton - activityVC.popoverPresentationController?.sourceRect = CGRectMake(10, 20, 0, 0) + activityVC.popoverPresentationController?.sourceRect = CGRect(x: 10, y: 20, width: 0, height: 0) - presentViewController(activityVC, animated: true, completion: nil) + present(activityVC, animated: true, completion: nil) } @IBAction func dismissKeyboard() { diff --git a/PasscodeLockDemo/UserDefaultsPasscodeRepository.swift b/PasscodeLockDemo/UserDefaultsPasscodeRepository.swift index 696171a3..a8e6b6dc 100644 --- a/PasscodeLockDemo/UserDefaultsPasscodeRepository.swift +++ b/PasscodeLockDemo/UserDefaultsPasscodeRepository.swift @@ -11,11 +11,11 @@ import PasscodeLock class UserDefaultsPasscodeRepository: PasscodeRepositoryType { - private let passcodeKey = "passcode.lock.passcode" + fileprivate let passcodeKey = "passcode.lock.passcode" - private lazy var defaults: NSUserDefaults = { + fileprivate lazy var defaults: UserDefaults = { - return NSUserDefaults.standardUserDefaults() + return UserDefaults.standard }() var hasPasscode: Bool { @@ -29,18 +29,18 @@ class UserDefaultsPasscodeRepository: PasscodeRepositoryType { var passcode: [String]? { - return defaults.valueForKey(passcodeKey) as? [String] ?? nil + return defaults.value(forKey: passcodeKey) as? [String] ?? nil } - func savePasscode(passcode: [String]) { + func savePasscode(_ passcode: [String]) { - defaults.setObject(passcode, forKey: passcodeKey) + defaults.set(passcode, forKey: passcodeKey) defaults.synchronize() } func deletePasscode() { - defaults.removeObjectForKey(passcodeKey) + defaults.removeObject(forKey: passcodeKey) defaults.synchronize() } } diff --git a/PasscodeLockTests/PasscodeLock/EnterPasscodeStateTests.swift b/PasscodeLockTests/PasscodeLock/EnterPasscodeStateTests.swift index 2e4dcf94..25c8696d 100644 --- a/PasscodeLockTests/PasscodeLock/EnterPasscodeStateTests.swift +++ b/PasscodeLockTests/PasscodeLock/EnterPasscodeStateTests.swift @@ -17,7 +17,7 @@ class NotificaionObserver: NSObject { let center = NSNotificationCenter.defaultCenter() - center.addObserver(self, selector: "handle:", name: notification, object: nil) + center.addObserver(self, selector: #selector(NotificaionObserver.handle(_:)), name: notification, object: nil) } func handle(notification: NSNotification) {