Collection of learnings and utilities in Swift.
Example for localizaing strings easier.
var localizedHelloWorld = "Hello World".localized
localizedHelloWorld = "Hello World".localized(comment: "Title for Hello World")
localizedHelloWorld = "Hello World".localizedWithComment("Title for Hello World")
Example for using synchronized in Swift.
Basic synchronized
synchronized(someObj) {
// Do something
}
Return a value from synchronized
let val: Int = synchronized(someObj) {
return 5
}
Return a value from synchronized and use someObj as input to closure
let val: Int = synchronizedWith(someObj) {
obj in
// Use obj to calculate some value
return 5
}