This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Populate the array with subarrays of [ColumnName, ColumnType] | |
// where columnType is one of: ["String", "Number", "Boolean", "Date", "File", "GeoPoint", "Array", "Object", "Pointer", "Relation"] | |
// Then, navigate to your Parse data class, copy paste this code into the console and hit enter | |
// populating this list will be very tedious if you do not take advantage of an awesome text editor like Sublime Text | |
var array = [["pooper", "String"], ["poopsToday", "Number"]] | |
var i = 0 | |
function addColumn() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Scenario: Parsing a JSON object that represents an item in a store | |
// JSON: { "name": "Bucket", "price": "19.95" } | |
// The following functions take in a price as a string, and output the result as an Int of cents | |
// cause I don't trust floating point operations when dealing with other people's money | |
struct Item { | |
let name: String | |
let price: Int | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- original | |
getBody :: ServerPart L.ByteString | |
parseBody :: FromJSON a => ServerPart (Maybe a) | |
parseBody = getBody >>= (return . A.decode) | |
-- attempt | |
parseBody :: FromJSON a => MaybeT (ServerPartT IO) a | |
parseBody = lift $ getBody >>= (return . A.decode) | |
-- Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Alamofire | |
import SwiftyJSON | |
class ViewController: UIViewController { | |
convenience init() { self.init(nibName: "ViewController", bundle: nil) } | |
@IBOutlet weak var label: UILabel! | |
override func viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import SwiftyJSON | |
struct NetworkClient { | |
static func makeRequest(url: String, | |
params: [String : AnyObject], | |
callback: (JSON?, ErrorType?) -> Void) | |
{ | |
request(.POST, url, parameters: params).response { _, _, data, error in | |
if let jsonData = data where error == nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import SwiftyJSON | |
import UIKit | |
class ViewController: UIViewController { | |
convenience init() { self.init(nibName: "ViewController", bundle: nil) } | |
@IBOutlet weak var label: UILabel! | |
override func viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Alamofire | |
import SwiftyJSON | |
class ViewController: UIViewController { | |
convenience init() { self.init(nibName: "ViewController", bundle: nil) } | |
@IBOutlet weak var label: UILabel! | |
var networkClient: NetworkClientType = NetworkClient() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import SwiftyJSON | |
protocol NetworkClientType { | |
func makeRequest(url: String, | |
params: [String : AnyObject], | |
callback: (JSON?, ErrorType?) -> Void) | |
} | |
struct NetworkClient: NetworkClientType { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import SwiftyJSON | |
protocol NetworkClientType { | |
func fetchUsername(callback: (String?, ErrorType?) -> Void) | |
func makeRequest(url: String, | |
params: [String : AnyObject], | |
callback: (JSON?, ErrorType?) -> Void) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alamofire | |
import SwiftyJSON | |
import UIKit | |
class ViewController: UIViewController { | |
convenience init() { self.init(nibName: "ViewController", bundle: nil) } | |
@IBOutlet weak var label: UILabel! | |
var networkClient: NetworkClientType = NetworkClient() | |
OlderNewer