Skip to content

Instantly share code, notes, and snippets.

@peterkos
Last active October 17, 2018 01:10
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 peterkos/b59407a858d3aab5ecef9a6b9672b42f to your computer and use it in GitHub Desktop.
Save peterkos/b59407a858d3aab5ecef9a6b9672b42f to your computer and use it in GitHub Desktop.
Code written on Week 1 of the iOS Development Workshop, Autumn 2018, w/ Dubstech
// -----------------------------------------
// Playground Code
// -----------------------------------------
import UIKit
var str = "Hello, playground"
// sayHello() prints "hello, person!"
func sayHello() {
print("hello, person")
}
// print "Hello, Peter!"
func sayHello(name: String) {
print("Hello, \(name)")
}
sayHello(name: "Peter")
func sayHello2(toPerson name: String) {
print("Hello, \(name)")
}
sayHello2(toPerson: "Peter")
// - >
func sayHello(toPerson name: String) -> String {
return "Hello, \(name)"
}
sayHello(toPerson: "Peter")
class Animal {
var name: String
// Constructor
init() {
name = ""
}
}
var dog = Animal()
dog.name = "Lola 🐕"
// -----------------------------------------
// iOS Project Code
// -----------------------------------------
// ViewController.swift
import UIKit
// class ViewController extends UiViewController
class ViewController: UIViewController {
@IBAction func theButton(_ sender: UIButton) {
print("Hello")
if let val = sender.accessibilityLabel {
print(val)
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment