background preloader

Swift

Facebook Twitter

Some links about the Swift language

Swift. Modern Swift is the result of the latest research on programming languages, combined with decades of experience building Apple platforms. Named parameters are expressed in a clean syntax that makes APIs in Swift even easier to read and maintain. Even better, you don’t even need to type semi-colons. Inferred types make code cleaner and less prone to mistakes, while modules eliminate headers and provide namespaces. To best support international languages and emoji, strings are Unicode-correct and use a UTF-8-based encoding to optimize performance for a wide variety of use cases.

Declare new types with modern, straightforward syntax. Add functionality to existing types using extensions, and cut down on boilerplate code with custom string interpolations. extension Player: Codable, Equatable {} import Foundation let encoder = JSONEncoder() try encoder.encode(player) print(player) Perform powerful custom transformations using streamlined closures. Designed for safety Fast and powerful Open source. The Swift Programming Language: About Swift. Swift is a 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. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun.

Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works. Swift has been years in the making. Apple laid the foundation for Swift by advancing our existing compiler, debugger, and framework infrastructure. Swift feels familiar to Objective-C developers. Swift is friendly to new programmers.

Swift combines the best in modern language thinking with wisdom from the wider Apple engineering culture. Swift is a fantastic way to write iOS and OS X apps, and will continue to evolve with new features and capabilities. Swift Cheat Sheet and Quick Reference. If you're new here, you may want to subscribe to my RSS feed or follow me on Twitter.

Thanks for visiting! Swift Cheat Sheet and Quick Reference Now Available! Update 6/3: Updated thanks to some helpful comments/suggestions from Chris Wagner, @Craimasjien, @Alarcon, @doTheTricks, and @rbnVnznz. Thanks all! I am up late tonight reading Apple’s Swift book and playing around with it a bit – there’s too much exciting stuff to sleep! There’s a lot of new syntax in Swift, so I thought it might be useful if if I put together a cheat sheet / quick reference on the language. Without further ado, here is the download link: Swift Cheat Sheet and Quick Reference It summarizes the most important Swift syntax on one page to get you up to speed quickly, including: Class ImplementationMethodsCreating/Using an ObjectDeclaring VariablesControl FlowString Quick ExamplesArray Quick ExamplesDictionary Quick Examples I’ve made sure to use only materials available to the public in the creation of this.

Swift & Cocoapods. Using Swift with Cocoa and Objective-C: Basic Setup. Swift is designed to provide seamless compatibility with Cocoa and Objective-C. You can use Objective-C APIs (ranging from system frameworks to your own custom code) in Swift, and you can use Swift APIs in Objective-C. This compatibility makes Swift an easy, convenient, and powerful tool to integrate into your Cocoa app development workflow. This guide covers three important aspects of this compatibility that you can use to your advantage when developing Cocoa apps: Interoperability lets you interface between Swift and Objective-C code, allowing you to use Swift classes in Objective-C and to take advantage of familiar Cocoa classes, patterns, and practices when writing Swift code. Mix and match allows you to create mixed-language apps containing both Swift and Objective-C files that can communicate with each other.

Before you get started learning about these features, you need a basic understanding of how to set up a Swift environment in which you can access Cocoa system frameworks. Erica Sadun » Swift: How to PROPERLY combine Objective C and Swift in a single project! (Part 2 of a series) Erica | 4:32 pm | June 3, 2014 | Development,Swift After some handholding help by Kevin Ballard, I managed to get everything working for some complex cross-platform code.

Here are the lessons along the way. There’s one entirely essential lesson, which is this: It’s not enough to just create a bridging header. If Xcode didn’t offer to build it on your behalf, you must manually add it to your build settings. Select your PROJECT > Build Settings and search for “bridging”. Set your Objective-C Bridging Header to your project-relative header file name. And now for the more amusing bits: Feel free to drop compatibility aliases and replace them with #defines. If you’re doing cross-platform development, make sure you import Foundation in your Objective C code before you do absolutely anything else. Lessee, what else? My original write-up on this topic can be found here. (Thanks Kevin and Remy!)

Learn Swift - Tutorials, Code Samples, References and more!