Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Swift 2 Blueprints
Swift 2 Blueprints

Swift 2 Blueprints: Swift Blueprints

eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Swift 2 Blueprints

Chapter 1. Exploring Xcode

Programming is not only about code, it is also about methodology. It doesn't matter how many years you've been programming with Xcode, there is always a new feature that can speed up your development, mainly nowadays that there is a new version every few months. Don't forget that Swift is a new language created to replace the old Objective-C, which means that Xcode also needs to adopt new features for this new programming language.

This book is about creating applications with the Swift programming language using Xcode 6 as an IDE. The idea behind these apps is to show how to create different kinds of real apps from scratch and this chapter presents with you some tricks on how to use Xcode.

Even if you are already a developer with years of experience in Xcode, it is worth reading this chapter because there is always a different way to do a task and it can be very helpful. So, let's start reviewing some Xcode and Swift features. In this chapter, we will cover:

  • Keyboard shortcuts
  • Versioning your project
  • Testing with Playground
  • Debugging
  • New Swift features
  • Some final comments

Keyboard shortcuts

Have you ever thought of how much time a developer expends in moving the mouse pointer? It can be a lot of time. How about reducing some time by memorizing a few key combinations. Of course, don't expect to memorize all of them in a day. You can practice them when it is necessary; you will see that, after a while, you will save a lot of time. Of course, command + X, command + C, command + V, and command + Q are not going to be mentioned for they are assumed to be known.

The first shortcut we are going to learn is command + B, which is to build the solution without running it on the device or simulator. This key combination is very useful when you want to check whether the project has any errors, but you don't want to waste time installing the app.

Sometimes, mainly when you have Swift and C on the same project, the compiler caches the object files wrongly, so the best solution would be to clean everything up and recompile again. To clean your entire project, use the command + shift + K combination. Cleaning is a fast process, nevertheless, you have to remember that afterward you need to rebuild your project, which might take a while.

If you want to build your product and run it, you have two options. The first is command + R that compiles your project if it is necessary and installs it on the device or simulator; this combination is equivalent to pressing play on the left-hand side of the toolbar. The second option is control + command + R, which installs the last build but doesn't rebuild the project; it is very handy when your project takes a long time to compile and you just want to reinstall it again for testing.

Now, let's learn some key combinations that will affect Xcode, visually speaking. On the left-hand side, we have the Navigator. As you know, here is where you can access the project files, the search results, and the compilation status. The following screenshot shows a sample of the Navigator:

Keyboard shortcuts

If you need more visual space, you can hide the Navigator area with command + 0, or you can show this area using the same combination. It is very useful when you have a small screen like a MacBook screen and you need to work with the interface builder or Playground.

As you can see, there is a bar on the top (called the Navigator bar), which allows you to access different sections of the Navigator. You can click on each icon or you can save some time by pressing command + a number from 1 to 8, 1 being the project navigator (folder icon), 2 the symbol navigator, and so on till 8, which is the report navigator.

Every Navigator section has a text field at the bottom to filter the content that is being displayed on the Navigator. You can reach this text field very fast by using the command + option + J combination. So, based on the previous combination, when you need to access a file, you can go to the project navigator by pressing command + 1 followed by command + option + J.

To finish with the Navigator area, you should know that you have a shortcut to go to the project navigator and highlight the current file, it is command + shift + J.

The area on the right-hand side is called the Utility area and its combinations are similar to the Navigator area. This area can be hidden or shown with command + option + 0, its sections can be accessed with command + option + a number from 1 to 6, and its filter can be reached with command + option + L. The following screenshot is a sample of the Utility area:

Keyboard shortcuts

The area located between the Navigators and the Utility area at the bottom of the Xcode screen is called the Debug area. This area can be shown or hidden with command + shift + Y. Here, you have some debug combinations like command + Y to enable or disable breakpoints or pause or resume the application with control + command + Y. There are more debugging keyboard shortcuts; as they require the use of fn keys (F6, F7, F8), it can be complicated according to your keyboard. Here, you have a sample of the Debug area:

Keyboard shortcuts

Now, the central area, which is the most important one, is called the Editor area. Here, as you know, is where you type your code. Scrolling up and down could waste a lot of time, so let's learn some shortcuts that will make us find our code faster. The first combination is command + F that opens a text field to search in the current file.

When you need to search in the whole project, you can use the command + shift + F combination, which is much faster than a click on the loupe icon and a click on the text field. Another similar combination is command + shift + O (letter O, not the number zero), which is called Open Quickly…. This combination opens a text field in front of your editor area and allows you to search for symbols. It also allows you to type the first letter of each symbol word, like the following example in which NSHD was typed and it was able to find NSHomeDirectory.

Keyboard shortcuts

Open Quickly searches for symbols in the current project and also inside the frameworks. But if you like to jump to a symbol (method, property, global variable, and so on), you can use control + 6 as it opens the combo box that is located at the top of the editor area like in the following screenshot:

Keyboard shortcuts

To navigate through the files you've been using, you can use control + command + to go to the previous files or control + command + for the next one. Alternatively, you can slide with two fingers on use the touch pad if you have one.

When you have a code that is quite difficult to understand because it is not well-formatted, you can use the control + I combination. If you have selected some lines, only these lines will be arranged. If no line is selected, then the current line of code will be formatted.

To finish this shortcuts section, it is worth mentioning that you have command + \ to toggle breakpoints and command + / to toggle the selected line comments.

Don't worry if you think that there are too many combinations to memorize or if some of them are hard to do, you can always check the combination and customize it if you want by opening the Xcode menu, selecting preferences, and opening the Key Bindings section like in the following screenshot:

Keyboard shortcuts

Tip

Bear in mind while customizing your shortcuts that when you work on another computer, you will have to set them up again.

Versioning your project

Every project should have a version control system, even if you are the only developer. Xcode works with Git as a default VCS, which has a special way of working.

Firstly, you have to know that Xcode offers you just the basic usage of Git; there are times when you might need to use the command line.

You can use Git in two ways: locally only or remote and locally. The first one is usually done by single developers and can be done very easily by checking this option when you have to select a folder for your new project. The following screenshot shows the option that needs to be checked in the file dialog:

Versioning your project

The second way of working with Git is to use it remotely and locally. What does it mean? It means that you can create versions of your code locally and when you think that it is ready to be shared with the other members of the team, you can send it to the server. To do so, you have to configure a server by yourself or you can use this service from a third-party company, such as GitHub or BitBucket.

Note

Recently, Apple announced the Xcode server, where you can configure your Git server and also a continuous integration system. Explaining how to configure this server can be very exhausting and is out of the scope of this book. However, if you would like to create your own server, you can have a look at this possibility.

As a developer what you need to work with a remote repository is its URL. You have to request it to the system administrator or you can copy it from the website where you created it. GitHub, for example, shows it on the right-hand side with a button to copy the URL on the clipboard, as you can see in the following screenshot:

Versioning your project

Once you have the URL, you can check it out by selecting the Check out an existing project option on the start up screen, as shown in the following screenshot. Or, you can click on the Source Control menu and select the Check out... option.

Versioning your project

Once you have your project checked out and have started working on it, it doesn't matter whether it was created from a server or locally only. You will notice that when a file is modified, letter M will appear next to your file name on the project navigator. Letter A will also appear when a new file is added to the project. The next screenshot shows a sample of some files that were added or modified:

Versioning your project

Note that letter M can also appear next to your project; it means that something in the project.pbxproj file, which is inside of your project package. This file contains the information of your project like the source code files with their path and the settings; hence, you have to deliver it every time you add a file or change any setting.

To commit the modified and new files, you just need to use the command + option + C key combination. A dialog asking for a description of the modifications will appear, leave a message in a way that another developer understands what was done.

Tip

Avoid committing without leaving a comment, or just leaving a nonexpressive comment like "modifications." Comments are very useful to check the project's progress and fix bugs.

These commits are done locally by default. It means that only your computer knows about your modifications. If you want to send your commits to the server, don't forget to check the option that is under the comment box, as it is demonstrated in the next screenshot:

Versioning your project

The other way around, which means receiving updates from the server, is called pull. To do a pull from the server, you just need to press the command + option + X combination key.

Testing with Playground

Playground is a new Xcode 6 feature that allows the programmer to see the Swift code result before it is added to the project. This way, you can test your code separately from the project, receive real-time execution and feedback, and apply it when you are really convinced.

You can use Playground as if it were a separate project by navigating to File | New | Playground…. This way, you can do your tests without saving it with the rest of the project.

The other use of Playground is to add it to your project, so you can save your tests with your project. To do this, just add a new file with command + N, select the iOS Source section, and select Playground, as shown in the following screenshot:

Testing with Playground

Even if Playground is inside your project or workspace, it won't be able to use your project classes. It means that you might have to copy some files into your Playground and be aware of the modifications, as they are considered to be different containers with their own dependencies.

Tip

Don't use Playground to benchmark or test sensors. It wasn't done for this purpose.

Let's make a sample to create a customized view with Playground. We will create a class called CustomView, which inherits from UIView. Add a yellow background and a red border. Place the following code to start testing with Playground:

class CustomView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.layer.borderColor = UIColor.redColor().CGColor
        self.backgroundColor = UIColor.yellowColor()
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Just below the code, you can create a frame and instantiate it:

var frame = CGRectMake(0, 0, 100, 100)
var myView = CustomView(frame: frame)

On the right-hand side, you will see the word CustomView appear. Move the mouse over this word and you will see two small icons appear. One of them is an eye called Quick Look. If you click on it, an image of your view will be displayed, as you can see in the following screenshot:

Testing with Playground

Here, for example, we can see that something is missing: the red border! The reason is that we are yet to set its width. Let's return to the initializer and add a border to our view:

        super.init(frame: frame)
        self.layer.borderWidth = 2
        self.layer.borderColor = UIColor.redColor().CGColor

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Now, you can check your view again using Quick Look. But if you want to get faster results, you can click on the circle icon that is to the right of the Quick Look icon. You will see your square under its declaration. Have a look at the following screenshot to see the expected result:

Testing with Playground

Let's make another change and see how fast Playground gives us results. Add a round corner to your view with the following code:

self.layer.cornerRadius = 15

As you could see, the Playground took approximately 1 second, as it needs to recompile the code, execute it, and retrieve the result. Don't think about what the sample does by itself. What you do have to think about is how much time you expend testing it on an app every time you have a change and how much time you expend testing it on Playground.

Note

For more information on how to use Playground, you can read Swift Cookbook by Packt Publishing.

Debugging

Debugging is an everyday task for a developer that is usually done to fix a bug. There is no right or wrong way for debugging, and there is no formula to find where the issue is. On the other hand, we have some tricks that can help us find where the bug is. In this section, you are going to see some of them. They can be very useful if you would like to modify any app in this book and you don't get the expected result.

First of all, let's see a common problem. Swift was created to be compatible with Objective-C and Objective-C in its early days was created to be some kind of Smalltalk over the C layer. The idea at that time was to create a language where containers and functions didn't need to be of only a specific type like an array of integers, even the value returned from a function could be of any type. You can see, for example, NSArray, NSDictionary, and NSSet that can store NSString, NSNumber, and the objects of any other class in the same container.

How Swift receives this kind of information? One way is by using generics but, usually, they are received as AnyObject. Sometimes, the debugger is not able to show you the right variable type. For a better example, have a look at the following code:

var request = NSURLRequest(URL: NSURL(string: "http://date.jsontest.com/")!)
NSURLSession.sharedSession().dataTaskWithRequest(request) { (data, response, error) -> Void in
    var json = NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers, error: nil)
    // json Type???
}.resume()

In this case, you can ask yourself what is the JSON variable type? Of course, the first step is to check the debugger information, but you might get some information like the following one:

Debugging

You can check with the is operator like if json is Int, but it can be very exhausting and, sometimes, even impossible. For scenarios like this, you can use the _stdlib_getDemangledTypeName function, which displays the variable type name. In this case, we can add the following println instruction to our code, as it is shown in the next code:

    var json = NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers, error: nil)
    println("json variable type: \( _stdlib_getDemangledTypeName(json!) )")
}.resume()

Now, you can see on the log console that, in this case, it is a dictionary as follows:

Debugging

Note

In Swift 2, many functions have changed their input or output header from AnyObject to a specific type, making life easier for developers.

Another important thing to bear in mind is lldb, which is the debugger command line. It can look complex and not much intuitive, but when you get used to it, it is very useful and logical. For example, you can set breakpoints using a pattern like br s -r viewDid* to add breakpoints in functions like viewDidLoad and viewDidAppear.

Of course, there are tasks that you can do with lldb and also with Xcode like using the lldb command po [[UIWindow keyWindow] recursiveDescription], which gives you the window view hierarchy, or simply using the new Debug View Hierarchy button (displayed next) that comes since Xcode 6, which gives you 3D information on the current view.

Debugging

Once it is pressed, you can rotate the image and have an output similar to the following screenshot:

Debugging

A very common problem in our apps is the excess of memory usage. When we start receiving memory warnings, we need to check the amount of memory that is being increased in some parts of our code. To do it, just keep a function to retrieve the memory whenever you want. The following code is valid to retrieve the amount of memory that is being consumed:

func getMemoryUsage() -> mach_vm_size_t{
    let MACH_TASK_BASIC_INFO_COUNT = sizeof(mach_task_basic_info_data_t) / sizeof(natural_t)

    let flavor = task_flavor_t(MACH_TASK_BASIC_INFO)
    var size   = mach_msg_type_number_t(MACH_TASK_BASIC_INFO_COUNT)
    var pointer = UnsafeMutablePointer<mach_task_basic_info>.alloc(1)
    let kerr = task_info(mach_task_self_, flavor, UnsafeMutablePointer(pointer), &size)
    let info = pointer.move()

    pointer.dealloc(1)

    if kerr == KERN_SUCCESS {
        return info.resident_size
    } else {
        let message = String(CString: mach_error_string(kerr), encoding: NSASCIIStringEncoding)!
        fatalError(message)
    }
}

Then, call this function in some parts of your code where you think there is memory wastage and print it like the following code:

println("File: \(__FILE__) at line \(__LINE__) memory usage \(getMemoryUsage())")

Note

There are third-party products that can also help you to debug your app like Fabric (http://www.fabric.io) that sends reports on user crashes to the developer.

New Swift features

Swift is a new language, but it has been changed a few times. While this book was being written, Swift had passed through the 1.2 and 2.0 versions. These versions have some syntax differences compared to the previous ones.

Before the Swift 1.2 version, you couldn't use more than one let statement on an if statement, so you probably had to write codes like the following one:

    if let name = product.name {
      if let category = product.category{
        if let price = product.price {
          if price >= 0 {
            println("The product is valid")
          }
        }
      }
    }

Now, you can reduce the number of lines and write a code like the next one:

    if let name = product.name, category = product.category, price = product.price where price >= 0 {
      println("The product is valid")
    }

Constants can be initialized after their declaration and before using them, like the following code:

    let discount:Double
    if onSale {
      discount = 0.2
    }else {
      discount = 0
    }

Downcasts and casts that don't return options must use the as! operator instead of the old as operator. It means that the casting from typical functions that return AnyObject must use the new operator. For example, the call to retrieve the index paths of a table view will be as follows:

var paths = tableView.indexPathsForRowsInRect(rect) as! [NSIndexPath]

If you have a huge project done with the first Swift version, you might be scared about the number of errors you have for small things like using the new as! operator. Fortunately, there is an option to update our Swift code in the Edit menu in order to convert our code to the latest Swift version syntax, as it is demonstrated in the following screenshot:

New Swift features

When Swift was announced, it brought with itself new data types that replaced the equivalent Objective-C containers, such as Array for NSArray, String to replace NSString, and Dictionary for NSDictionary, but there was a missing type: NSSet. Now, there is Set that follows the same rule as its colleagues: it must specify the data type that it will store (generics) and it is interchangeable with NSSet.

A new attribute was introduced in the Swift language, it is called final. If you have a final class, no class can inherit from it. If you have an attribute or a method, you can't override it.

Some final comments

Working with someone else's code might be a difficult task; you have to figure out what is the logic of the previous developer and how you could change the code to fix a bug, for example. This is the reason why developers must think like a team, act as a team, and work in a team. What does this mean? As a part of our tasks, we should help the next developer by adding comments for them. Swift has its own features based on comments.

Firstly, an interesting part is that Swift allows nested multiline comments. It means that a comment like the following one is not going to stop before println like the other languages do:

        /*
          This code was removed due to it is a bit buggy
          /*
            for i in myArray {
              object.process(i)
            }
          */
          println(myObject.description)
        */

Another good thing that we could do with comments is to mark the current state of development. This is equivalent to the #pragma preprocessor in Objective-C. Let's start with // MARK: -, this allows us to add a title before each section of our class. For example, imagine that we have a big class, so we can use this mark to show which methods belong to the base class, which ones belong to the delegates, and which ones are private methods. In this case, we would have a code similar to the following one:

    // MARK: - Overriden functions
    override func viewDidLoad() {
      super.viewDidLoad()
      //…
    }
    // continue overriding some methods
    // MARK: - Delegates
    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath){
    //…
    }
    // continue writing some delegates methods
    // MARK: - private methods
    private func createTitle(cellNumber: Int) -> String {
    //…

In this case, when you click on the editor's combo box (or press control + 6 as we learned before), you might see a combo similar to the following screenshot:

Some final comments

This kind of mark can also be used to reach a differentiated code (something you might check frequently) but, in this case, it is recommended to use it without the dash character, something like // MARK: Important code, and it can be done anywhere, even in half a function. Removing the dash from // MARK: removes the dividing line in the combo box.

When you have an incomplete code or task, you can mark it with // TODO:, meaning that something is pending in this area. For example, imagine that there is a code that is hardcoded and it is desired to load the information from a configuration file. You might have a code similar to the following:

// TODO: Retrieve this IP address from the configuration file
return "192.168.20.21"

The next mark we have is // FIXME:, it represents that this part of the code has a known issue and it should be fixed. Something like the following:

// FIXME: The app hangs when there is not internet connection
myconnection.retrieveInformationFromServer()

Tip

Try to search for TODO: and FIXME: frequently or do a script that searches for them. There are times when there are too many codes to fix and nobody cares about it.

While you finish this part, don't forget that a well-documented code is a helpful code. When you hold the option key and click over a symbol, you will see some information on that symbol, like the NSURLRequest box shown in the following screenshot:

Some final comments

You can display equivalent information from your classes, methods, and properties by using HereDoc. The idea is very simple; you can take advantage of the comments by starting with ///, followed by its description as follows:

/// A class that represents a garage with its cars
class Garage {

Of course, this format is fine when the description is short. However, if you need to write a more exhaustive description, you'd better use the multiline comments starting with /** and closing it with */.

You can also describe the arguments and the value returned with :param: and :returns: as shown in the following code:

    /**
     Sell a product and remove it from the current stock.
    
     Remember that:
    
     - The product must be available
     - the quantity can't be 0 or negative
    
     :param: product The product you are selling
     :param: quantity Number of units or kilos to sell
     :returns: if the purchase was done correctly
    */
    func sellProduct (product: Product, quantity: Int) -> Bool{

For example, this code will generate the following box:

Some final comments

Summary

In this introductory chapter, we discussed about the basics of Xcode. You learned important keyboard shortcuts that helped us speed up the development. You learned how to set up a project and how to work with this IDE like testing with Playground and using the Git version control.

In the next chapter, we are going to start our first app from scratch. You will learn some of the basic features of the Swift programming language.

Left arrow icon Right arrow icon

Key benefits

  • Develop a variety of iOS-compatible applications that range from health and fitness to utilities using this project-based handbook
  • Discover ways to make the best use of the latest features in Swift to build on a wide array of applications
  • Follow step-by-step instructions to create Swift apps oriented for the real world

Description

In this book, you will work through seven different projects to get you hands-on with developing amazing applications for iOS devices. We start off with a project that teaches you how to build a utility app using Swift. Moving on, we cover the concepts behind developing an entertainment or social networking related application, for example, a small application that helps you to share images, audio, and video files from one device to another. You’ll also be guided through create a city information app with customized table views, a reminder app for the Apple Watch, and a game app using SpriteKit. By the end of this book, you will have the required skillset to develop various types of iOS applications with Swift that can run on different iOS devices. You will also be well versed with complex techniques that can be used to enhance the performance of your applications.

Who is this book for?

If you are a competent iOS developer who wants to develop stunning applications with Swift, then this book is for you. Familiarity with Swift programming is assumed.

What you will learn

  • Get to grips with the basics of Xcode and Swift for application development
  • Create a Photo Sharing application to capture an image, edit it using different features and share it via social media.
  • Develop applications using the WatchKit and exchange data between iPhone and the Watch
  • Use advanced features such as SpriteKit to build a game
  • Install third-party Swift frameworks to improvise on your application development
  • Discover how to simulate home automation with HomeKit
  • Build an application to monitor the user s weight, heart rate and the number of steps for Health Historic Analysis
  • Manipulate media using AVFoundation framework to merge audio and video.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 27, 2015
Length: 276 pages
Edition : 1st
Language : English
ISBN-13 : 9781783980765
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 27, 2015
Length: 276 pages
Edition : 1st
Language : English
ISBN-13 : 9781783980765
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 112.97
Swift 2 Design Patterns
$26.99
Swift High Performance
$36.99
Swift 2 Blueprints
$48.99
Total $ 112.97 Stars icon

Table of Contents

9 Chapters
1. Exploring Xcode Chevron down icon Chevron up icon
2. Creating a City Information App with Customized Table Views Chevron down icon Chevron up icon
3. Creating a Photo Sharing App Chevron down icon Chevron up icon
4. Simulating Home Automation with HomeKit Chevron down icon Chevron up icon
5. Health Analyzing App Using HealthKit Chevron down icon Chevron up icon
6. Creating a Game App Using SpriteKit Chevron down icon Chevron up icon
7. Creating an Apple Watch App Chevron down icon Chevron up icon
8. AVFoundation Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(4 Ratings)
5 star 25%
4 star 75%
3 star 0%
2 star 0%
1 star 0%
G. Campbell Jan 23, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I really like this book. The introduction which covers Xcode (keyboard shortcuts, version control, testing a UIView in playground, etc.) were helpful, and you can tell this was written by working developers. The sample apps are well presented and the practical approach is carried forward throughout. I think anyone developing apps with Xcode would benefit from this book.
Amazon Verified review Amazon
Robert D. Matthews Dec 10, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I purchased this book from Packt publishing, as I have done a lot with other titles lately.The book is pretty good. I'd probably give it 4.5 stars if that were an option. Very few books will ever get 5 stars.The book starts off with a pretty quick overview on xcode, etc. and then jumps right into talking you through making 7 different apps.The strategy of walking you through is pretty good, it get's your hands dirty and your head around the kinds of things you have to do to make an app. It's not designed to be a technical resource and the book doesn't cover everything, but it does a great job with focusing on several aspects of making an app using swift and some of the right things to do and the wrong things to avoid. They don't spend any time with CoreData but they do throw in a watch app.Overall it's a great book...probably not the first book on iOS programming someone should read but it's a great hands-on walkthrough for someone new to swift.It's a very good technical book for what it's intended for.
Amazon Verified review Amazon
pauland Dec 08, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I'm not new to Swift development but bought this book primarily to get a 'quick start' to building some types of projects and to get an insight into the techniques others are using when building swift applications. This book does not disappoint in that respect.Essentially the book is divided into chapters, with each chapter (except the first) being a run-through of the building of an application. You can see the list of applications from the book preview, but the applications include APIs introduced in IOS9 and the Apple watch.Each application build is well described with all stages of the design and build process explained, though I would say that this is not going to be an easy read for someone who has no experience of IOS/Swift development. It definitely helps to have an idea of the basic concepts first.The book is an excellent resource for building projects quickly. Many of the steps of building typical apps are explained well here, so it forms an excellent resource when a client wants an app that is similar to those presented in the book. It does what it says on the cover - provide a set of swift 2 blueprints/templates that you can build-out as-is or use and adapt in other projects.I am really pleased by the technical content of the book and it is going to speed up my development.In terms of production quality - it is very typically a Packt book. No colour at all in the print version, so greyscale. I really hate greyscale! I wish they would have colour in their books - it would make the book easier to read.I also have an electronic version of the book and that has colour, though disappointingly almost all of the code listings do not have the colour syntax highlights that you would see when working with XCode.I am really pleased with the book and happy to recommend it. It would be five stars if Packt had produced it in colour with colour syntax highlights.
Amazon Verified review Amazon
CandaceVan Nov 22, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I picked up this book because I've been working my way through Swift by Example (also published by Packt), and this looked like a similar kind of book that would teach me how to use some of the frameworks (both Apple and 3rd-party) available to use in iOS development.This is not a beginning book. It assumes that you are familiar with both Xcode and Swift, and after a brief review, it plunges into seven very different projects that range from manipulating photos to creating a 2D game to creating an app for an Apple Watch. Aside from a bit of non-traditional English (clearly comprehensible although obviously written by a non-native author), I have found this book to be, so far, to be a very worthwhile purchase. I'll update my review if my opinion changes by the end of the book!Here's a roundup of what is specifically in the book:Swift 2 Blueprints by Cecil Costa (known as Eduardo Campos in Latin countries), published Oct. 2015 by Packt Publishing, 276 pages. Eight chapters.Chapter 1, "Exploring Xcode," reviews Xcode and Swift features, including: keyboard shortcuts, versioning (Git), testing with playground, debugging (use of _is_ operator, lldb, Fabric), new Swift features (lifting of _let_ limitations, _as_ operator, and introduction of _Set_ to replace _NSSet_).Chapter 2, "Creating a City Information App with Customized Table Views," uses the SwiftyJSON framework to work with JSON messages.Chapter 3, "Creating a Photo Sharing App," teaches how to use the camera, edit a photo, and share it using a social framework.Chapter 4, "Simulating Home Automation with HomeKit," shows how to simulate a house with various devices and create an app to retrieve device info as well as change their settings.Chapter 5, "Health Analyzing App Using HealthKit," teaches the use of HealthKit, as well as a 3rd-party framework, iOS Chart.Chapter 6, "Creating a Game App Using SpriteKit," a framework made for the development of 2-dimensional games.Chapter 7, "Creating an Apple Watch App," develops an app that controls a refrigerator. The amount of food available can be displayed on the watch.Chapter 8, "AVFoundation," uses this low-level framework to change the audio of an existing video from the photo gallery. It will also use the photos framework.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.