Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 762 Bytes

README.md

File metadata and controls

38 lines (32 loc) · 762 Bytes

Swiftly

Collection of learnings and utilities in Swift.

Localization

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")

Synchronization

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
}