Skip to content

Commit

Permalink
Merge pull request #316 from kishikawakatsumi/kk/readme
Browse files Browse the repository at this point in the history
Update code in documentation to Swift 3
  • Loading branch information
kishikawakatsumi authored Mar 30, 2017
2 parents cccf25f + 525537c commit bcd9c91
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ keychain["kishikawakatsumi"] = "01234567-89ab-cdef-0123-456789abcdef"
#### Saving Internet Password

```swift
let keychain = Keychain(server: "https://github.com", protocolType: .HTTPS)
let keychain = Keychain(server: "https://github.com", protocolType: .https)
keychain["kishikawakatsumi"] = "01234567-89ab-cdef-0123-456789abcdef"
```

Expand All @@ -60,11 +60,11 @@ let keychain = Keychain(service: "com.example.github-token", accessGroup: "12ABC
#### Create Keychain for Internet Password

```swift
let keychain = Keychain(server: "https://github.com", protocolType: .HTTPS)
let keychain = Keychain(server: "https://github.com", protocolType: .https)
```

```swift
let keychain = Keychain(server: "https://github.com", protocolType: .HTTPS, authenticationType: .HTMLForm)
let keychain = Keychain(server: "https://github.com", protocolType: .https, authenticationType: .htmlForm)
```

### :key: Adding an item
Expand Down Expand Up @@ -163,7 +163,7 @@ do {
### :key: Set Label and Comment

```swift
let keychain = Keychain(server: "https://github.com", protocolType: .HTTPS)
let keychain = Keychain(server: "https://github.com", protocolType: .https)
do {
try keychain
.label("github.com (kishikawakatsumi)")
Expand Down Expand Up @@ -242,7 +242,7 @@ let keychain = Keychain(service: "com.example.github-token")

```swift
let keychain = Keychain(service: "com.example.github-token")
.accessibility(.AfterFirstUnlock)
.accessibility(.afterFirstUnlock)

keychain["kishikawakatsumi"] = "01234567-89ab-cdef-0123-456789abcdef"
```
Expand All @@ -267,7 +267,7 @@ do {

```swift
let keychain = Keychain(service: "com.example.github-token")
.accessibility(.WhenUnlocked)
.accessibility(.whenUnlocked)

keychain["kishikawakatsumi"] = "01234567-89ab-cdef-0123-456789abcdef"
```
Expand Down Expand Up @@ -329,11 +329,11 @@ If you want to store the Touch ID protected Keychain item, specify `accessibilit
```swift
let keychain = Keychain(service: "com.example.github-token")

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
DispatchQueue.global().async {
do {
// Should be the secret invalidated when passcode is removed? If not then use `.WhenUnlocked`
try keychain
.accessibility(.WhenPasscodeSetThisDeviceOnly, authenticationPolicy: .UserPresence)
.accessibility(.whenPasscodeSetThisDeviceOnly, authenticationPolicy: .userPresence)
.set("01234567-89ab-cdef-0123-456789abcdef", key: "kishikawakatsumi")
} catch let error {
// Error handling if needed...
Expand All @@ -354,7 +354,7 @@ If the item not protected, the `authenticationPrompt` parameter just be ignored.
```swift
let keychain = Keychain(service: "com.example.github-token")

DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {
DispatchQueue.global().async {
do {
// Should be the secret invalidated when passcode is removed? If not then use `.WhenUnlocked`
try keychain
Expand All @@ -376,7 +376,7 @@ If the item not protected, the `authenticationPrompt` parameter just be ignored.
```swift
let keychain = Keychain(service: "com.example.github-token")

DispatchQueue.global(qos: DispatchQoS.QoSClass.default).async {
DispatchQueue.global().async {
do {
let password = try keychain
.authenticationPrompt("Authenticate to login to server")
Expand Down Expand Up @@ -477,16 +477,16 @@ let password = Keychain.generatePassword() // => Nhu-GKm-s3n-pMx
#### Display all stored items if print keychain object

```swift
let keychain = Keychain(server: "https://github.com", protocolType: .HTTPS)
let keychain = Keychain(server: "https://github.com", protocolType: .https)
print("\(keychain)")
```

```
=>
[
[authenticationType: Default, key: kishikawakatsumi, server: github.com, class: InternetPassword, protocol: HTTPS]
[authenticationType: Default, key: hirohamada, server: github.com, class: InternetPassword, protocol: HTTPS]
[authenticationType: Default, key: honeylemon, server: github.com, class: InternetPassword, protocol: HTTPS]
[authenticationType: default, key: kishikawakatsumi, server: github.com, class: internetPassword, protocol: https]
[authenticationType: default, key: hirohamada, server: github.com, class: internetPassword, protocol: https]
[authenticationType: default, key: honeylemon, server: github.com, class: internetPassword, protocol: https]
]
```

Expand Down Expand Up @@ -521,9 +521,9 @@ for item in items {

```
=>
item: [authenticationType: Default, key: kishikawakatsumi, server: github.com, class: InternetPassword, protocol: HTTPS]
item: [authenticationType: Default, key: hirohamada, server: github.com, class: InternetPassword, protocol: HTTPS]
item: [authenticationType: Default, key: honeylemon, server: github.com, class: InternetPassword, protocol: HTTPS]
item: [authenticationType: Default, key: kishikawakatsumi, server: github.com, class: InternetPassword, protocol: https]
item: [authenticationType: Default, key: hirohamada, server: github.com, class: InternetPassword, protocol: https]
item: [authenticationType: Default, key: honeylemon, server: github.com, class: InternetPassword, protocol: https]
```

## Requirements
Expand Down

0 comments on commit bcd9c91

Please sign in to comment.