Skip to content

Instantly share code, notes, and snippets.

View jquave's full-sized avatar
✔️
jquave

Jameson Quave jquave

✔️
jquave
View GitHub Profile
@jquave
jquave / SwiftTable
Created June 2, 2014 20:58
Example code for Table View in Swift
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
@jquave
jquave / Swift Part 2 jamesonquave.com
Created June 3, 2014 00:37
Part 2 of the Swift tutorial at jamesonquave.com
//
// ViewController.swift
// TestSwift
//
// Created by Jameson Quave on 6/2/14.
// Copyright (c) 2014 JQ Software LLC. All rights reserved.
//
import UIKit
@jquave
jquave / jamesonquave.com comment reply
Created June 3, 2014 01:05
jamesonquave.com comment reply
import UIKit
class AnotherClass {
var someVar = 1
let someConst = 2
func somePrivateFunc() -> Bool {
return true
}
@jquave
jquave / cellForRowAtIndexPath function in jamesonquave.com tutorial
Created June 4, 2014 17:09
cellForRowAtIndexPath function in jamesonquave.com tutorial
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
}
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
// Add a check to make sure this exists
@jquave
jquave / cellForRowAtIndexPath function in jamesonquave.com tutorial
Created June 4, 2014 17:20
cellForRowAtIndexPath function in jamesonquave.com tutorial
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
}
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
// Add a check to make sure this exists
@jquave
jquave / cellForRowAtIndexPath function in jamesonquave.com tutorial
Created June 4, 2014 18:04
cellForRowAtIndexPath function in jamesonquave.com tutorial
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
}
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
// Add a check to make sure this exists
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
}
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
// Add a check to make sure this exists
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: kCellIdentifier)
}
var rowData: NSDictionary = self.tableData[indexPath.row] as NSDictionary
// Add a check to make sure this exists
@jquave
jquave / JamesonQuave.com iOS 8 Swift Tutorial Part 6 cellForRowAtIndexPath
Created June 6, 2014 17:04
JamesonQuave.com iOS 8 Swift Tutorial Part 6 cellForRowAtIndexPath
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
// Find this cell's album by passing in the indexPath.row to the subscript method for an array of type Album[]
let album = self.albums[indexPath.row]
cell.text = album.title
cell.image = UIImage(named: "Blank52")
cell.detailTextLabel.text = album.price
In your APIController:
Modify the protocol to understand arrays:
protocol APIControllerProtocol {
func didRecieveAPIResults(results: NSDictionary)
func didRecieveAPIResults(results: NSArray)
}
Add a get function to perform arbitrary gets on URLs