Skip to content

Instantly share code, notes, and snippets.

@clooth
Created June 15, 2015 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clooth/fd3f7e9865978c6bfb09 to your computer and use it in GitHub Desktop.
Save clooth/fd3f7e9865978c6bfb09 to your computer and use it in GitHub Desktop.
// Grab API instance
let API = APIClient.instance
// Attempt to authenticate with username and password
let Authentication = API.authenticate(username, password: password)
Authentication.onSuccess { user in
println("Logged in as \(user.userName!)!")
// Load user images after a successful sign-in
let UserImages = API.imagesForUserId(user.id!, nextToken: nil)
UserImages.onSuccess { images in
println("Loaded \(images.count) images for \(user.userName!).")
}
// In case of error
UserImages.onFailure { error in
println("Failed to load user images: \(error.localizedDescription)")
}
}
Authentication.onFailure { error in
println("Failed to authenticate user \(username): \(error.localizedDescription)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment