Skip to content

Commit

Permalink
Merge pull request #77 from kishikawakatsumi/swift-2.0
Browse files Browse the repository at this point in the history
Swift 2.0
  • Loading branch information
kishikawakatsumi committed Sep 19, 2015
2 parents 9966e42 + 444b25a commit fb31ae7
Show file tree
Hide file tree
Showing 18 changed files with 895 additions and 867 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: beta-xcode6.3
osx_image: xcode7
cache:
directories:
- Lib/vendor/bundle
Expand All @@ -10,6 +10,7 @@ script:
branches:
only:
- master
- swift-2.0
env:
global:
- LANG=en_US.UTF-8
Expand Down
1 change: 1 addition & 0 deletions Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
14DAEE881A51E1BE0070B77E /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0620;
ORGANIZATIONNAME = "kishikawa katsumi";
TargetAttributes = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.8">
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -62,6 +62,8 @@
ReferencedContainer = "container:Example-iOS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -71,6 +73,7 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class AccountsViewController: UITableViewController {
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)

let services = Array(itemsGroupedByService!.keys)
let service = services[indexPath.section]
Expand Down
20 changes: 17 additions & 3 deletions Examples/Example-iOS/Example-iOS/InputViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,28 @@ class InputViewController: UITableViewController {
}

@IBAction func saveAction(sender: UIBarButtonItem) {
let keychain = Keychain(service: serviceField.text)
keychain[usernameField.text] = passwordField.text
let keychain: Keychain
if let service = serviceField.text where !service.isEmpty {
keychain = Keychain(service: service)
} else {
keychain = Keychain()
}
keychain[usernameField.text!] = passwordField.text

dismissViewControllerAnimated(true, completion: nil)
}

@IBAction func editingChanged(sender: UITextField) {
saveButton.enabled = !usernameField.text.isEmpty && !passwordField.text.isEmpty
switch (usernameField.text, passwordField.text) {
case let (username?, password?):
saveButton.enabled = !username.isEmpty && !password.isEmpty
case (_?, nil):
saveButton.enabled = false
case (nil, _?):
saveButton.enabled = false
case (nil, nil):
saveButton.enabled = false
}
}

}
2 changes: 1 addition & 1 deletion Examples/Playground-iOS.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='3.0' sdk='iphonesimulator' auto-termination-delay='0'>
<playground version='3.0' sdk='iphonesimulator' auto-termination-delay='0' runInFullSimulator='YES'>
<sections>
<code source-file-name='section-1.swift'/>
</sections>
Expand Down
22 changes: 11 additions & 11 deletions Examples/Playground-iOS.playground/section-1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ keychain.remove("kishikawakatsumi")

/* set */
if let error = keychain.set("01234567-89ab-cdef-0123-456789abcdef", key: "kishikawakatsumi") {
println("error: \(error.localizedDescription)")
print("error: \(error.localizedDescription)")
}

/* get */
Expand All @@ -72,28 +72,28 @@ let failable = keychain.getStringOrError("kishikawakatsumi")
// 1. check the enum state
switch failable {
case .Success:
println("token: \(failable.value)")
print("token: \(failable.value)")
case .Failure:
println("error: \(failable.error)")
print("error: \(failable.error)")
}

// 2. check the error object
if let error = failable.error {
println("error: \(failable.error)")
print("error: \(failable.error)")
} else {
println("token: \(failable.value)")
print("token: \(failable.value)")
}

// 3. check the failed property
if failable.failed {
println("error: \(failable.error)")
print("error: \(failable.error)")
} else {
println("token: \(failable.value)")
print("token: \(failable.value)")
}

/* remove */
if let error = keychain.remove("kishikawakatsumi") {
println("error: \(error.localizedDescription)")
print("error: \(error.localizedDescription)")
}


Expand Down Expand Up @@ -143,16 +143,16 @@ keychain

/* Display all stored items if print keychain object */
keychain = Keychain(server: NSURL(string: "https://github.com")!, protocolType: .HTTPS)
println("\(keychain)")
print("\(keychain)")

/* Obtaining all stored keys */
let keys = keychain.allKeys()
for key in keys {
println("key: \(key)")
print("key: \(key)")
}

/* Obtaining all stored items */
let items = keychain.allItems()
for item in items {
println("item: \(item)")
print("item: \(item)")
}
3 changes: 2 additions & 1 deletion KeychainAccess.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "KeychainAccess"
s.version = "1.2.1"
s.version = "2.0.0"
s.summary = "KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X."
s.description = <<-DESC
KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X.
Expand All @@ -24,6 +24,7 @@ Pod::Spec.new do |s|

s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.9"
s.watchos.deployment_target = '2.0'
s.requires_arc = true

s.source_files = 'Lib/KeychainAccess/*.swift'
Expand Down

0 comments on commit fb31ae7

Please sign in to comment.