Skip to content

Instantly share code, notes, and snippets.

View joshuawright11's full-sized avatar
🧪

Josh Wright joshuawright11

🧪
View GitHub Profile
@joshuawright11
joshuawright11 / Stuff.txt
Created April 28, 2015 04:55
A sample gist
Stuff
func mockData() -> [Annotation] {
return ["a","b","c","d","e","f","g"].map({
let annotationJSON: JSON = [
"location":[
"id":$0,
"metadata":[
"latitude":0.0,
"longitude":0.0]
@joshuawright11
joshuawright11 / keyboard.swift
Last active May 16, 2017 19:15
Animate on keyboard show and dismiss
override func viewDidLoad() {
// ...
Utils.registerForNotification(self, selector: #selector(MyViewController.keyboardShow(_:)), name: NSNotification.Name.UIKeyboardWillShow.rawValue)
Utils.registerForNotification(self, selector: #selector(MyViewController.keyboardHide(_:)), name: NSNotification.Name.UIKeyboardWillHide.rawValue)
// ...
}
func keyboardShow(_ notification: Notification){
//
// Observable.swift
// Created by Josh Wright on 9/1/17.
//
import UIKit
class Observable<T>: NSObject {
public typealias ValueChanged = (T) -> Void
import UIKit
struct TableViewRow {
var type: UITableViewCell.Type
var cellConfiguration: ((_ cell: UITableViewCell) -> Void)?
var action: (() -> Void)?
// Base static class to setup functionality and any custom design across all static views
class StaticTableViewBase: UITableViewController {
private var sections: [TableViewSection] = []
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(BasicCell.self)
tableView.register(FancyCell.self)
@joshuawright11
joshuawright11 / carla_notes_sept27.md
Last active October 2, 2017 20:39
Notes for September 27th session

Overview

Xcode and iOS Apps

  • Views are in .storyboard files
  • code that operates on the views is in a UIViewController
  • a UIViewController is linked to each screen in the storyboard

The Code

  • Variables (also known as Objects): Store data about something (such as a UILabel in the view, or a piece of text)
  • Functions: named blocks of code that can be run
@joshuawright11
joshuawright11 / carla_notes_oct2.md
Last active October 3, 2017 07:14
Notes for October 2nd session

Programming

  • Computer/Phone runs the program line by line
  • 'Comments' are used to tell the computer to ignore lines of code (useful for keeping notes in the code)
  • in Swift comments are created with // for single line comments or /* stuff here */ for multi-line comments

Swift

  • The language we have been working with. Created by Apple and primarily used for making iPhone/Mac apps.
  • 'Statically typed'

Functions

Each function has

  • parameters (what variables the function takes)
  • return type (what the fucntion returns, if anything)
// No return type
func printNum(num: Int) {
 print(num)

Control Structures

Control structures are things you can put in your code to perform various logic operations. (i.e. perform a line of code multiple times)

There are a few but there are 2 important ones to know:

  • if statments
  • for loops

if Statements