Swift Cookbook - 50 Recipes to Help You Harness Swift

Swift Cookbook - 50 Recipes to Help You Harness Swift

Cecil Costa

Language: English

Pages: 365

ISBN: 1784391379

Format: PDF / Kindle (mobi) / ePub


Key Features

  • Get familiar with the features of Xcode 6 with Swift to write code that is shorter, clearer, and runs faster on today s multi-core architectures
  • Packed with practical recipes that will help you gain an extra edge and use Apple s new programming language like a professional
  • Build your portfolio with Swift code using this hands-on guide

Book Description

If you have been looking for a book to help you develop apps for iOS on native iOS platforms, this is the book that you've been looking for! This practical guide will supply you with the building blocks that you can turn to when conceptualizing and writing applications for iOS/OS X. You'll master Swift programming as you progress through the various recipes in this book.

Starting with recipes that use the basic features, you will move on to interesting and engaging recipes that will make use of the more complex features of Swift. You will learn how to make use of Swift's diverse features, from the way you can configure your projects to the usage of design patterns and different types of databases. Complete with tips and tricks on Xcode, this example-based guide will help you develop and debug faster.

What you will learn

  • Install the latest version of Xcode and use all of its tools
  • Develop a multi-language project using Swift, Objective-C, C, and other languages
  • Plan your Swift project and explore the nuts and bolts of the Swift syntax
  • Use Swift playgrounds to see and hear your code's results as you write it
  • Localize your issues using the LLDB debugger and explore different possibilities of code with Swift playgrounds

About the Author

Cecil Costa, also know as Eduardo Campos in Latin countries, is a Euro-Brazilian freelance developer who has been learning about computers since getting his first 286 in 1990. From then on, he kept learning about programming languages, computer architecture, and computer science theory. Learning is his passion as well as teaching; this is the reason why he worked as a trainer, giving on-site courses for companies such as Ericsson, Roche, TVE (a Spanish television channel), and lots of other companies. Nowadays, he also teaches through online platforms, helping people from every part of the world.

Table of Contents

  1. Getting Started with Xcode and Swift
  2. Standard Library and Collections
  3. Using Structs and Generics
  4. Design Patterns with Swift
  5. Multitasking
  6. Playground
  7. Swift Debugging with Xcode
  8. Integrating with Objective-C
  9. Dealing with Other Languages
  10. Data Access
  11. Miscellaneous

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

them on Mac OS X if you want. Creating HTML manually HTML started as a simple format for displaying web pages and links. Nowadays, this format has become very common and it is used everywhere. There are even frameworks such as PhoneGap that create applications with this file type. In this recipe, we will create HTML using only strings; the main idea is to know about string manipulation. In this case, we will create the HTML code for a visiting card. Getting ready Open your Xcode and create a

other functions or algorithms.Tip Implement the Comparable or Equatable protocols when you can use it with other generic objects, for example, when you think the object could be ordered. A good feature of Swift is that you don't need to overload only existing operators; you can also create new operators. In this case, we will create two new operators, => that will tell us whether a product is in our shopping list and !=>, which is the opposite operator. I will explain in detail later. Use these

you should migrate your old code to the new Swift language. If you would like to keep your application core on Objective-C, that's ok, but remember that the new features are going to be added to Swift, and it will be difficult to keep two languages in the same project. In this recipe, we are going to port part of the code, which is written in Objective-C to Swift. Getting ready Make a copy of the previous recipe. If you are using any version control system, this is a good time to commit your

"EOR %[first],%[first], %[second] \n\t" : /* outputs */ [first]"=r"(*firstnumber), [second]"=r"(*secondnumber) : /* inputs */ [first]"r"(*firstnumber), [second]"r"(*secondnumber) ); #else #error "Architecture not allowed" #endif } The assembly part is done; click on the storyboard and create a layout with two labels, two text fields, and a button. Change the labels' text to First Number and Second Number. On the text fields, replace the place holders with some sample numbers and change the

target and add a framework called CoreImage. After this, go to the storyboard, add an image view, and four buttons under it. Change the button's labels to Take photo, Sepia, Blur, and Dots.Connect the image with the view controller as an attribute and call it imageView. Now, create one action for each button and call them takePhoto, sepia, blur, and dots. Don't worry about their contents now; we will fill them later: @IBOutlet var imageView: UIImageView! @IBAction func takePhoto(sender: UIButton)

Download sample

Download