Swift 2

Value types in swift are:

structs (incl. arrays and dictionaries)
enumerations
basic data types (boolean, integer, float, etc.)

Implicit

Swift doesn’t define any implicit cast between data types, even if they are conceptually almost identical (like UInt and Int).

To fix the error, rather than casting, an explicit conversion is required. In the sample code, all expression operands must be converted to a common same type, which in this case is Double:

var result = Double(op1) + Double(op2) + op3

http://www.toptal.com/swift/interview-questions
In Swift enumerations, what’s the difference between raw values and associated values?

swift automatically bridges: number types to NSNumber strings to NSString arrays to NSArray dictionaries to NSDictionary which are all reference types.
There is a strong reference cycle between Master and Detail, with Master creating an instance of Detail and storing a reference to it, and Detail storing a reference to the instance of its Master creator. In both cases, references are strong, which means that none of the 2 instances will ever be deallocated, causing a memory leak.

To solve the problem it’s necessary to break at least one of the 2 strong relationships, by using either the weak or unowned modifier. The differences between the 2 modifiers is:

unowned: the reference is assumed to always have a value during its lifetime - as a consequence, the property must be of non-optional type.
weak: at some point it’s possible for the reference to have no value - as a consequence, the property must be of optional type.


Structures are value types. By default, the properties of a value type cannot be modified from within its instance methods.

However, you can optionally allow such modification to occur by declaring the instance methods as ‘mutating’; e.g.:

struct IntStack {
  var items = [Int]()
  mutating func add(x: Int) {
    items.append(x) // All good!
  }
}

functions:

def someFnWithFirstArg(arg1 firstArg:String, _ secondArg:String)->{
firstArg+secondArg
}

someFnWithFirstArg(arg1:"fghfh","fgfh")

Note: In swift its not garbage collection, its reference counting. Object always lives in the heap, so no & or *.

  • In swift all properties have to initialized when the object is initialized