Swift 2

Swift. A modern programming language that is safe, fast, and interactive.


Swift is a powerful and intuitive programming language for iOS, OS X, tvOS, and watchOS. Writing Swift code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next project — or addition into your current app — because Swift code works side-by-side with Objective-C.

Introducing Swift 2

Swift has been refined from the ground up. It generates faster code across the board, both for release and debug builds. The Swift compiler is also faster, even while adding new Fix-it suggestions such as where you can use let instead of var. Comments can include Markdown syntax to add rich text and embedded images that display in Xcode’s Quick Help. A new assistant shows your Swift API in a “header-like” view. And new syntax features combined with improvements to the Cocoa frameworks and Objective-C will make your code more expressive, and even safer.

Error handling model

An advanced error handling model provides clear, expressive syntax for catching and throwing errors. It’s also easy to create your own custom error types so you can describe error cases with clear, meaningful names. The new error model was designed to work seamlessly with NSError and the Cocoa frameworks. Error handling code now looks like:

func loadData() throws { }

func test() {
	do {
		try loadData()
	} catch {


You should always use the latest SDK to get access to the latest features, documentation, and API changes, but sometimes your app needs to run on an older OS. Swift 2.0 has built-in availability checking to make it easy to build the best possible app for each target OS version. The compiler will give you an error when using an API too new for your minimum target OS, and a new keyword lets you wrap blocks of code in a conditional version check to run only on specific OS releases.

Syntax improvements

New syntax features let you write more expressive code while improving consistency across the language. The SDKs have employed new Objective-C features such as generics and nullability annotation to make Swift code even cleaner and safer. Here is just a sampling of Swift 2.0 enhancements.

  • Powerful control flow with do, guard, defer, and repeat
  • Keyword naming rules unified for functions and methods
  • Protocol extensions and default implementations
  • Extended pattern matching to work in if clauses and for loops

Xcode 7 includes a powerful migrator that will help convert your application and playground code to work with the latest syntax improvements in Swift 2.0.

Open Source

Swift is developed in the open with source code, a bug tracker, mailing lists, and regular development builds available for everyone. The broad community of developers, both inside and outside of Apple, are working together to make Swift even more amazing. Swift already has support for all Apple platforms as well as Linux, with new platforms to come. We can’t wait to see all the places where Swift can make software safer and faster, while also making programming more fun.


Swift is the result of the latest research on programming languages, combined with decades of experience building Apple platforms. Named parameters brought forward from Objective-C are expressed in a clean syntax that makes APIs in Swift even easier to read and maintain. Inferred types make code cleaner and less prone to mistakes, while modules eliminate headers and provide namespaces. Memory is managed automatically, and you don’t even need to type semi-colons. All this modern thinking results in a language that is easy and fun to use.

extension String {
    var banana : String {
    	let shortName = String(characters.dropFirst(1))
    	return "\(self) \(self) Bo B\(shortName) Banana Fana Fo F\(shortName)"

let bananaName = "Jimmy".banana		// "Jimmy Jimmy Bo Bimmy Banana Fana Fo Fimmy"

16 thoughts on “Swift 2”

  1. We are a bunch of volunteers and starting a new scheme in our community. Your site provided us with helpful information to work on. You’ve done an impressive activity and our whole community shall be grateful to you.

  2. Hmm is anyone else having problems with the pictures on this blog loading? I’m trying to determine if its a problem on my end or if it’s the blog. Any suggestions would be greatly appreciated.

  3. Hi blogger !! I read your blog everyday and i must say you have very interesting articles here.

    Your page deserves to go viral. You need initial traffic only.
    How to go viral fast? Search for; forbesden’s tools

  4. Thank you for all of the work on this web site. My mother take interest in working on investigations and it is simple to grasp why. I notice all about the dynamic manner you render sensible steps by means of this website and invigorate participation from others about this matter and our own princess has been starting to learn so much. Take advantage of the rest of the new year. Your carrying out a wonderful job.

  5. I together with my friends appeared to be following the nice pointers found on the website and so immediately got an awful feeling I had not thanked the website owner for them. My people were definitely as a consequence warmed to learn them and have honestly been tapping into these things. Many thanks for truly being well accommodating as well as for finding variety of excellent ideas millions of individuals are really needing to learn about. Our sincere regret for not expressing appreciation to you sooner.

  6. Thank you so much for providing individuals with an extraordinarily marvellous chance to check tips from this web site. It can be very enjoyable and also stuffed with fun for me and my office colleagues to search the blog not less than three times in 7 days to find out the newest guides you have got. And of course, I’m just at all times amazed with your terrific advice served by you. Selected two areas in this article are rather the most effective I have had.

  7. My wife and i were very comfortable Jordan managed to finish up his web research with the precious recommendations he made from your own web site. It’s not at all simplistic to simply be making a gift of ideas other people have been trying to sell. And we all realize we’ve got the blog owner to give thanks to for this. The type of explanations you made, the simple blog navigation, the relationships you will assist to promote – it’s got many exceptional, and it’s assisting our son in addition to the family reason why that concept is awesome, which is especially essential. Thank you for the whole lot!

Leave a Reply

Your email address will not be published. Required fields are marked *