A Developing Blog

Swift

Swift


Playing around with custom operators… which seems to confuse the html formatter…






import UIKit

infix operator |> { associativity left precedence 180 }

func |> (lhs: Int, rhs: Int) -> Int {

return lhs+rhs
}

class TestThis {

func doTest() {
print("This is a test")
print(3 |> 12 |> 10)
}

}







Code to figure out how many weeks in a month…


func weeksInMonth(month: Int, year: Int) -> (Int)? {

let calendar = NSCalendar.currentCalendar()

let comps = NSDateComponents()
comps.
month = month+1
comps.
year = year
comps.
day = 0

guard let last = calendar.dateFromComponents(comps)
else {
return nil
}

let tag = calendar.components([.WeekOfMonth,.WeekOfYear,
.YearForWeekOfYear,.Weekday,.Quarter], fromDate: last)

return tag.weekOfMonth

}

if let numWeeks = weeksInMonth(5,year: 2015) {
print(numWeeks)
}





Good swift reference
http://appventure.me/2015/10/24/swift-reflection-api-what-you-can-do/

NSCoding and Swift Structs
http://swiftandpainless.com/nscoding-and-swift-structs/




Good tutorial on creating a 3 node cluster

https://cloud.google.com/container-engine/docs/tutorials/hello-node#step_3_create_your_cluster

And, here's the more advanced one…

https://cloud.google.com/container-engine/docs/tutorials/guestbook



Comments

Technical

Beginning of the blog page…decided to go with RapidWeaver 6, even after being burned with the no backup option.
Comments