Localization for swift

demo Open Xcode and click on File->New->Project… to create a new project, choose Single View Application. Select Swift for the language project and name it as you want, personally I called it “LocalizationTutorial” Click on your project icon (the blue icon) in your directory hierarchy on the left hand side, to “Info”. Now click on […]

Separate Delegate and DataSource of UITableView from your ViewController

Step 1 demo – simple table step 2 demo – pull out the data source step 3 demo – pull out table view delegates Step 1

Step 2 – pulling out the Data Source In order to declare a data source, we first create an object that houses the data to represent the rows […]

type inference

the compiler will infer the type of variable or constant, based on what is being assigned to it.

Comments and Quick Help

// MARK: this is viewable in the jump bar // TODO: Do This // FIXME: fix this /// A Quick Help comment /// /// – warning: integer must be > 0 /// – parameter integer: Integer to square /// /// – returns ‘integer’ squared func doSomething() { }

Value types vs Reference types in swift (advanced)

ref – https://www.raywenderlich.com/112029/reference-value-types-in-swift-part-2 Mixing Value and Reference Types You’ll often run into situations where reference types need to contain value types, and vice versa. This can easily complicate the expected semantics of the object. To see some of these complications, you’ll look at an example of each scenario. Reference Types Containing Value Type Properties It’s […]

Value types vs Reference types in swift (basics)

ref – https://www.raywenderlich.com/112027/reference-value-types-in-swift-part-1 Value types keep a unique copy of their data, while reference types share a single copy of their data. Reference type Swift represents a reference type as a class. This is similar to Objective-C, where everything that inherits from NSObject is stored as a reference type. In Objective-C — and most other […]

Selector and UIButton in swift

swift 3.0 Given

should now be written as

If you were to follow swift 3 guidelines for declaring functions

in that case, we’ll have to declare our selector like so:

In a Single View App

If you want to pass in additional information into the sample function, you can over-ride […]

GCD in swift

ref – http://www.appcoda.com/grand-central-dispatch/ Queue A queue is actually a block of code that can be executed synchronously or asynchronously, either on the main or on a background thread. Once a queue is created, the operating system is the one that manages it and gives it time to be processed on any core of the CPU. […]

Arrays (swift)

In Swift, arrays are implemented as structs, making them value types rather than reference types (i.e., classes). When a value type is assigned to a variable as an argument to a function or method, a copy is created and assigned or passed. Let’s take a look at an example of an Array

Here we […]