KEMBAR78
The Swift Programming Language with iOS App | PDF
IOS 8 Features
and
Swift Development
Presenter: Vivek Chaudhary, Mindfire Solutions
Date: 08/05/2013
๏ƒ’ IOS 8 Features
๏ƒ’ Swift Development
๏ƒ’ Syntax and Basics
๏ƒ’ Objective C to Swift
๏ƒ’ Sample Code
๏ƒ’ Pros and Cons
๏ƒ’ Battery usage indicator
๏ƒ’ Interactive Notifications
๏ƒ’ Credit Card Scanning
๏ƒ’ New keyboard
๏ƒ’ Continuity
๏ƒ’ Family Sharing
๏ƒ’ Message UI and new widgets
๏ƒ’ Lock screen app suggestions
๏ƒ’ Healthkit
๏ƒ’ Improved search results
๏ƒ’ Some syntax from Java Script
๏ƒ’ Smartly detects data types itself
๏ƒ’ Objective C API + Additional
๏ƒ’ No semicolon
๏ƒ’ Body Braces compulsory for If-else
๏ƒ’ Single file in place of two files (.h and .m)
๏ƒ’ Declaration and implementation in the same
file
๏ƒ’ Reduces the project size
๏ƒ’ Number of files reduces to half
1. let someConstant : String = โ€œconstantโ€
2. var someVar : String = โ€œvariableโ€
๏ƒ’ Swift is smart enough to detect data types
๏ƒ’ Var someVar = โ€œvariableโ€
๏ƒ’ Var var1 = 1
๏ƒ’ Var var2 = 1.0
๏ƒ’ NSString and String both are available
1. Let string = โ€œHelloโ€
2. Let anotherString = string + โ€œMindfireโ€
1. For char in str
2. {
3. // Code Here
4. }
๏ƒ’ Objective C
๏ƒ’ [NSString stringWithFormat:]
๏ƒ’ Swift
๏ƒ’ (expression)
๏ƒ’ Let var1 = 2
๏ƒ’ Let var2 = 3
๏ƒ’ Println( โ€œMultiplication is : (var1 * var2)โ€)
1. let someArray:String[] = [โ€œAโ€, โ€œBโ€, โ€œCโ€]
2. let someArray = [โ€œAโ€, โ€œBโ€, โ€œCโ€]
3. var someArray:String[] = [โ€œAโ€, โ€œBโ€, โ€œCโ€]
4. SomeArray += โ€œDโ€
5. SomeArray += [โ€œDโ€, โ€œEโ€]
6. print(โ€œFirst Element :(someArray[0]) โ€)
1. let dict:Dictionary<String, String> = [โ€œAโ€:โ€1โ€,
โ€œBโ€:โ€2โ€]
2. var dict:Dictionary<String, String> = [โ€œAโ€:โ€1โ€,
โ€œBโ€:โ€2โ€]
3. var dict = [โ€œAโ€:โ€1โ€, โ€œBโ€:โ€2โ€]
1. dict[โ€œCโ€] = โ€œ3โ€
2. Dict += [โ€œDโ€:โ€4โ€, โ€œEโ€:โ€5โ€]
๏ƒ’ + and โ€“ are sliced off.
func functionName(var1:String, var2:String)-
>String
๏ƒ’ Functions can return more than one
parameters too.
๏ƒ’ These are returned in the form of tuples.
Function Definition
func functionName(var1:String, var2:String)-
>(String, Int)
Function Calling
Var result : (res1:String, res2:Int) =
self.functionName(var1:โ€Helloโ€, var2:โ€Mobileโ€)
Print(โ€œresult is (result.res1)โ€;
๏ƒ’ Type id changes to AnyObject
๏ƒ’ Downcast is done automatically by swift.
๏ƒ’ โ€œasโ€ keyword is used to typecast
Var textField: UITextField = array.firstObject() as
UITextField
One has to manually change his Objective C code
to Swift
๏ƒ’ - changes to func
๏ƒ’ + changes to class func
๏ƒ’ #define changes to let
๏ƒ’ #pragma changes to // MARK :
๏ƒ’ init is not used in swift.
๏ƒ’ InitWith and with is also not used.
๏ƒ’ Complex macros should be converted into
functions
Let myColor = UIColor(red:0.5,
green:0.5,blue:0.5, alpha:1.0);
PLAYGROUNDS
REFRENCE LINKS
https://developer.apple.com/library/prerelease/i
os/documentation/Swift/Conceptual/BuildingCo
coaApps/
http://code.tutsplus.com/tutorials/an-
introduction-to-swift-part-1--cms-21389
Presenter: Debasish Mohanty, Mindfire Solutions
Thank you
๏Š
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-solutions
http://twitter.com/mindfires

The Swift Programming Language with iOS App

  • 1.
    IOS 8 Features and SwiftDevelopment Presenter: Vivek Chaudhary, Mindfire Solutions Date: 08/05/2013
  • 2.
    ๏ƒ’ IOS 8Features ๏ƒ’ Swift Development ๏ƒ’ Syntax and Basics ๏ƒ’ Objective C to Swift ๏ƒ’ Sample Code ๏ƒ’ Pros and Cons
  • 3.
    ๏ƒ’ Battery usageindicator ๏ƒ’ Interactive Notifications ๏ƒ’ Credit Card Scanning ๏ƒ’ New keyboard ๏ƒ’ Continuity ๏ƒ’ Family Sharing
  • 4.
    ๏ƒ’ Message UIand new widgets ๏ƒ’ Lock screen app suggestions ๏ƒ’ Healthkit ๏ƒ’ Improved search results
  • 5.
    ๏ƒ’ Some syntaxfrom Java Script ๏ƒ’ Smartly detects data types itself ๏ƒ’ Objective C API + Additional ๏ƒ’ No semicolon ๏ƒ’ Body Braces compulsory for If-else
  • 6.
    ๏ƒ’ Single filein place of two files (.h and .m) ๏ƒ’ Declaration and implementation in the same file ๏ƒ’ Reduces the project size ๏ƒ’ Number of files reduces to half
  • 7.
    1. let someConstant: String = โ€œconstantโ€ 2. var someVar : String = โ€œvariableโ€ ๏ƒ’ Swift is smart enough to detect data types ๏ƒ’ Var someVar = โ€œvariableโ€ ๏ƒ’ Var var1 = 1 ๏ƒ’ Var var2 = 1.0
  • 8.
    ๏ƒ’ NSString andString both are available 1. Let string = โ€œHelloโ€ 2. Let anotherString = string + โ€œMindfireโ€ 1. For char in str 2. { 3. // Code Here 4. }
  • 9.
    ๏ƒ’ Objective C ๏ƒ’[NSString stringWithFormat:] ๏ƒ’ Swift ๏ƒ’ (expression) ๏ƒ’ Let var1 = 2 ๏ƒ’ Let var2 = 3 ๏ƒ’ Println( โ€œMultiplication is : (var1 * var2)โ€)
  • 10.
    1. let someArray:String[]= [โ€œAโ€, โ€œBโ€, โ€œCโ€] 2. let someArray = [โ€œAโ€, โ€œBโ€, โ€œCโ€] 3. var someArray:String[] = [โ€œAโ€, โ€œBโ€, โ€œCโ€] 4. SomeArray += โ€œDโ€ 5. SomeArray += [โ€œDโ€, โ€œEโ€] 6. print(โ€œFirst Element :(someArray[0]) โ€)
  • 11.
    1. let dict:Dictionary<String,String> = [โ€œAโ€:โ€1โ€, โ€œBโ€:โ€2โ€] 2. var dict:Dictionary<String, String> = [โ€œAโ€:โ€1โ€, โ€œBโ€:โ€2โ€] 3. var dict = [โ€œAโ€:โ€1โ€, โ€œBโ€:โ€2โ€] 1. dict[โ€œCโ€] = โ€œ3โ€ 2. Dict += [โ€œDโ€:โ€4โ€, โ€œEโ€:โ€5โ€]
  • 12.
    ๏ƒ’ + andโ€“ are sliced off. func functionName(var1:String, var2:String)- >String ๏ƒ’ Functions can return more than one parameters too. ๏ƒ’ These are returned in the form of tuples.
  • 13.
    Function Definition func functionName(var1:String,var2:String)- >(String, Int) Function Calling Var result : (res1:String, res2:Int) = self.functionName(var1:โ€Helloโ€, var2:โ€Mobileโ€) Print(โ€œresult is (result.res1)โ€;
  • 14.
    ๏ƒ’ Type idchanges to AnyObject ๏ƒ’ Downcast is done automatically by swift. ๏ƒ’ โ€œasโ€ keyword is used to typecast Var textField: UITextField = array.firstObject() as UITextField
  • 15.
    One has tomanually change his Objective C code to Swift ๏ƒ’ - changes to func ๏ƒ’ + changes to class func ๏ƒ’ #define changes to let ๏ƒ’ #pragma changes to // MARK :
  • 16.
    ๏ƒ’ init isnot used in swift. ๏ƒ’ InitWith and with is also not used. ๏ƒ’ Complex macros should be converted into functions Let myColor = UIColor(red:0.5, green:0.5,blue:0.5, alpha:1.0);
  • 17.
  • 19.
  • 20.
    Presenter: Debasish Mohanty,Mindfire Solutions Thank you ๏Š
  • 21.