Wednesday, July 16, 2014

Swift - String in swift [ swift programming language apple ios]

Strings  “Swift strings are represented by the String type, which in turn represents a collection of values of Character type.” “Unicode-compliant way to work with text in your code. ” “Swift’s String type is bridged seamlessly to Foundation’s NSString class. ” “Each Character value represents a single Unicode character.” “+” to concate...

Swift - Some basic about swift / let var in swift [ swift programming language apple ios]

basic no smicolon(“Semicolons are required, however, if you want to write multiple separate statements on a single line:” Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/in/jEUH0.l), no backet for if , for loop, while loop let - constant var for variable defualt compulsory for switch, no break All swift code...

Swift - Basic data types in swift [ swift programming language apple ios]

Integer UInt8, Int32,Int64,UInt32,UInt64 etc Float Double,Float “Double has a precision of at least 15 decimal digits, whereas the precision of Float can be as little as 6 decimal digits.” BOOL Bool Boolean constant values, true and false:” Swift’s type safety prevents non-Boolean values from being be substituted for Bool. The following...

Swift - Generics (like template in c++) [ swift programming language apple ios]

Generics (like template in c++) “func repeat<ItemType>(item: ItemType, times: Int) -> ItemType[] {     var result = ItemType[]()     for i in 0..times {         result += item     }     return result } repeat("knock", 4)” “// Reimplement the Swift standard library's optional...

Swift - category in Swift / Extension in swift [ swift programming language apple ios]

Extension like category “Use extension to add functionality to an existing type, such as new methods and computed properties. ” “extension Int: ExampleProtocol {     var simpleDescription: String {     return "The number \(self)"     }     mutating func adjust() {         self +=...

Swift - Protocol in swift [ swift programming language apple ios]

Protocol “Classes, enumerations, and structs can all adopt protocols.” protocol ExampleProtocol {     var simpleDescription: String { get }     mutating func adjust() } struct SimpleStructure: ExampleProtocol {     var simpleDescription: String = "A simple structure"     mutating func adjust() {  ...

Swift - enum / Enumeration [ swift programming language apple ios]

enum enum like classes and have methods inside it. enum Rank: Int {     case Ace = 1     case Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten     case Jack, Queen, King     func simpleDescription() -> String {         switch self {         case .Ace:  ...

Swift - Classes / Classes in Swift [ swift programming language apple ios]

Classes:- use class keyword followed by classname class Shape  {     var numberOfSides = 0     func simpleDescription() -> String {         return "A shape with \(numberOfSides) sides."     } } var shape = Shape() shape.numberOfSides = 7 var shapeDescription = shape.simpleDescription() class...

Swift - Function declaration and defination [ swift programming language apple ios]

Function declaration and defination “Use func to declare a function.” “func greet(name: String, day: String) -> String {     return "Hello \(name), today is \(day)." }” “Functions can be nested.” Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/in/jEUH0.l return multiple values “func getGasPrices()...

About

Powered by Blogger.