Skip to content

Instantly share code, notes, and snippets.

View charleshkang's full-sized avatar

Charles Kang charleshkang

View GitHub Profile
/*
Below is a code that creates an array of Cat objects and an array
of their meowPatterns.
Can you match pattern with the cat, store the pattern variable inside the
Cat and modify the “meow” function to print either “MEOW” or “meow”?
1. Match the meowPatterns with cats and store its pattern inside the Cat
object
//
// MainViewController.swift
// Badges
//
// Created by Charles Kang on 6/14/16.
// Copyright © 2016 Charles Kang. All rights reserved.
//
import UIKit
import SwiftyJSON
//
// BadgeAPI.swift
// Badges
//
// Created by Charles Kang on 6/15/16.
// Copyright © 2016 Charles Kang. All rights reserved.
//
import Foundation
import SwiftyJSON
import Foundation
import SwiftyJSON
class BadgeAPI {
public func main(function: Void -> Void) {
dispatch_async(dispatch_get_main_queue(), function)
let jsonURL = "http://www.khanacademy.org/api/v1/badges"
class func parseBadgeJSON ()
{
let jsonURL = "http://www.khanacademy.org/api/v1/badges"
if let url = NSURL(string: jsonURL) {
if let data = try? NSData(contentsOfURL: url, options: []) {
let json = JSON(data: data)
fetchBadgeJSON(json)
}
//
// MainViewController.swift
// Badges
//
// Created by Charles Kang on 6/14/16.
// Copyright © 2016 Charles Kang. All rights reserved.
//
import UIKit
import SwiftyJSON
//
// CMLoginViewController.swift
// Coffee Mapper
//
// Created by Charles Kang on 4/13/16.
// Copyright © 2016 Charles Kang. All rights reserved.
//
import UIKit
//
// LoginViewController.swift
// FirebaseJokes
//
// Created by Matthew Maher on 1/23/16.
// Copyright © 2016 Matt Maher. All rights reserved.
//
import UIKit
@IBAction func signUpButtonTapped(sender: AnyObject)
{
let username = usernameTextField.text
let email = emailTextField.text
let password = passwordTextField.text
if username != "" && email != "" && password != "" {
DataService.dataService.BASE_REF.createUser(email, password: password, withValueCompletionBlock: { error, result in
if error != nil {3
self.signupErrorAlert("Oops!", message: "Having some trouble creating your account. Please try again.")
@IBAction func createAccount(sender: AnyObject) {
let username = usernameField.text
let email = emailField.text
let password = passwordField.text
if username != "" && email != "" && password != "" {
// Set Email and Password for the New User.
DataService.dataService.BASE_REF.createUser(email, password: password, withValueCompletionBlock: { error, result in