Skip to content

Instantly share code, notes, and snippets.

View helloworldsmart's full-sized avatar
😀
I may be slow to respond.

MichaelChen helloworldsmart

😀
I may be slow to respond.
  • Mars
View GitHub Profile
[
{
"StationID": "string",
"StationName": {
"Zh_tw": "string",
"En": "string"
},
"StationPosition": {
"PositionLat": 0,
"PositionLon": 0
class ImageViewController: UIViewController
{
//1. model
// var imageURL: URL?
//5.
var imageURL: URL? {
didSet {
image = nil
//fetchImage()
import UIKit
class ViewController: UIViewController {
//MART: 1. @IBOutlet weak var faceView: FaceView!
//MART: 9.
/*
IBOutletweak var faceView: FaceView! {
didSet {
class FaceView: UIView {
//MARK
//Don't type infer
@IBInspectable
var scale: CGFloat = 0.9 { didSet{setNeedsDisplay()} }
@IBInspectable
var eyesOpen: Bool = true { didSet{setNeedsDisplay()} }
import UIKit
@IBDesignable
class FaceView: UIView {
//Don't type infer
@IBInspectable
var scale: CGFloat = 0.9
@IBInspectable
@helloworldsmart
helloworldsmart / CatEatSwift.swift
Last active January 20, 2017 09:02
設計一個 func printer(mode: Int, size: Int) mode = 0 時會用 * 印出一個直角三角形 mode = 1 時則會用 * 印出一個等腰三角形 size 為三角形的高度 (共幾層 * 堆疊)
func printer(mode: Int, size: Int) {
guard size >= 2 else { return }
switch mode {
case 0:
for i in 1...size {
for _ in 1...i {
print("*", terminator: "")
}
print("")
}
@helloworldsmart
helloworldsmart / CatEatSwift
Created December 8, 2016 07:59
strategy pattern ?
//: __Problem 4__
//:
//: __4a.__
//: Write an instance method, bark(), that returns a different string based on the value of the stored property, size.
enum Size: Int {
case small
case medium
case large
}
@helloworldsmart
helloworldsmart / CatEatSwift
Last active November 30, 2016 08:23
drawGeometry
enum Geometry: Int {
case triangle = 3
case square = 4
case pentagon = 5
case hexagon = 6
}
func drawGeometry(stepsLabel: Int, sides: Geometry) {
let count = sides.rawValue
let exteriorAngle = 360 / count
@helloworldsmart
helloworldsmart / CatEatSwift
Last active November 5, 2016 10:08
inout便利貼
//inout類似C++傳遞引用
var image = [
[3, 7, 10],
[6, 4, 2],
[8, 5, 4]
]
func raiseLowerValueOfImage(_ image:inout [[Int]]) {
for row in 0..<image.count {
for color in 0..<image[row].count {
@helloworldsmart
helloworldsmart / CatEatSwift
Last active November 5, 2016 09:21
Optional便利貼
```swift=
func perform(operation:String, a:Double, b:Double) -> Double! {
var result:Double?
switch operation {
case "+":
result = a + b
case "-":
result = a - b
case "/":
result = a / b