The Swift Programming Language with iOS App

Click here to load reader

  • date post

  • Category


  • view

  • download


Embed Size (px)


Swift is the latest new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility. This presentation is all about swift programming along with major iOS 8 Features and changes.

Transcript of The Swift Programming Language with iOS App

  • 1.IOS 8 Features and Swift Development Presenter: Vivek Chaudhary, Mindfire Solutions Date: 08/05/2013

2. IOS 8 Features Swift Development Syntax and Basics Objective C to Swift Sample Code Pros and Cons 3. Battery usage indicator Interactive Notifications Credit Card Scanning New keyboard Continuity Family Sharing 4. Message UI and new widgets Lock screen app suggestions Healthkit Improved search results 5. Some syntax from Java Script Smartly detects data types itself Objective C API + Additional No semicolon Body Braces compulsory for If-else 6. 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 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 and String 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 = [A:1, B:2] 2. var dict:Dictionary = [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 id changes to AnyObject Downcast is done automatically by swift. as keyword is used to typecast Var textField: UITextField = array.firstObject() as UITextField 15. 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 : 16. 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); 17. PLAYGROUNDS 18. REFRENCE LINKS os/documentation/Swift/Conceptual/BuildingCo coaApps/ introduction-to-swift-part-1--cms-21389 19. Presenter: Debasish Mohanty, Mindfire Solutions Thank you 20.