O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learn iOS 11 Programming with Swift 4 - Second Edition

Book Description

Begin your iOS development journey using Swift 4 and XCode 9 with this easy to learn, practical guide.

About This Book

  • Explore the latest features of iOS 11 and Swift 4 to build robust applications
  • Kickstart your iOS development career by building your first application from scratch
  • Manage databases and integrate standard elements such as photos and GPS into your app

Who This Book Is For

This book is for beginners who want to be able to create iOS applications. You do not need any knowledge of Swift or any prior programming experience. However, if you have some programming experience, this book is a great way to get a full understanding of how to create an iOS application from scratch and submit it to the App Store

What You Will Learn

  • Get to grips with Swift 4 and Xcode 9, the building blocks of Apple development
  • Get to know the fundamentals of Swift 4, including strings, variables, constants, and control flow
  • Discover the distinctive design principles that define the iOS user experience
  • Build a responsive UI and add privacy to your custom-rich notifications
  • Preserve data and manipulate images with filters and effects
  • Bring in SiriKit to create payment requests inside your app
  • Collect valuable feedback with TestFlight before you release your apps on the App Store

In Detail

You want to build iOS applications but where do you start? Forget sifting through tutorials and blog posts, this book is a direct route into iOS development, taking you through the basics and showing you how to put the principles into practice. So take advantage of this developer-friendly guide and start building applications that may just take the App Store by storm!

Whether you're an experienced programmer or a complete novice, this book guides you through every facet of iOS development. From Xcode and Swift, the building blocks of modern iOS development, you'll quickly gain a solid foundation to begin venturing deeper into your development journey. Experienced programmers can jump right in and learn the latest iOS 11 features.

You'll also learn advanced topics of iOS design, such as gestures and animations, to give your app the edge. Explore the latest developments in Swift 4 and iOS 11 by incorporating new features, custom-rich notifications, drag and drop features, and the latest developments in SiriKit. With further guidance on beta testing with TestFlight, you'll quickly learn everything you need to get your project on the App Store!

Style and approach

Step by step practical guide covering an example throughout the project

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. 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.

Table of Contents

  1. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  2. Getting Familiar with Xcode
    1. Getting started
    2. The Xcode interface
      1. Navigator panel
      2. Standard editor
      3. Utilities panel
      4. Debug panel
      5. Toolbar
      6. Generic iOS device
      7. iOS device
      8. Connecting wirelessly
      9. Window pane controls
    3. Summary
  3. Building a Foundation with Swift
    1. Playgrounds – an interactive coding environment
    2. Data types – where it all starts
      1. String
      2. Integer data type
      3. Floating-point numbers
      4. Booleans
      5. Variables and constants – where data is held
        1. Creating a variable with a string
        2. Creating a variable with an integer (Int)
        3. Debug and print() – detecting your bugs
        4. Adding floating-point numbers
        5. Creating a Boolean
        6. Hungarian notation
        7. Why constants versus variables?
      6. Comments – leaving yourself notes or reminders
    3. Type safety and type inference
      1. Concatenating strings
      2. String interpolation
    4. Operations with our integers
      1. Increment and decrement
      2. Comparison operators
    5. Summary
  4. Building on the Swift Foundation
    1. Creating a Playground project
    2. The if statements – having fun with logic statements
    3. Optionals and optional bindings
      1. Why optionals?
    4. Functions
    5. Summary
  5. Digging Deeper
    1. Creating a Playground project
    2. Ranges
      1. Closed range
      2. Half-closed range
    3. Control flow
      1. The for...in loop
      2. One-sided range
      3. The while loop
      4. The repeat...while loop
    4. Summary
  6. Digging into Collections
    1. Arrays
      1. Creating an empty array
      2. Creating an array with initial values
      3. Creating a mutable array
      4. Adding items to an array
      5. Checking the number of elements in an array
      6. Checking for an empty array
      7. Retrieving a value from an array
      8. Iterating over an array
      9. Removing items from an array
    2. Dictionaries
      1. Creating a dictionary
      2. Adding and updating dictionary elements
      3. Accessing an item in a dictionary
      4. Iterating over dictionary values
      5. Iterating over dictionary keys
      6. Iterating over dictionary keys and values
      7. Checking the number of items in a dictionary
      8. Removing items from a dictionary
    3. Sets
      1. Creating an empty set
      2. Creating a set with an array literal
      3. Creating a mutable set
      4. Adding items into a set
      5. Checking if a set contains an item
      6. Iterating over a set
      7. Intersecting two sets
      8. Joining two sets
      9. Removing items from a set
    4. Summary
  7. Starting the UI Setup
    1. Useful terms
      1. View Controller
      2. Table View Controller
      3. Collection View Controller
      4. Navigation Controller
      5. Tab Bar Controller
      6. Storyboard
      7. Segue
      8. Auto Layout
      9. Model View Controller (MVC)
    2. App tour
      1. Explore tab
      2. Locations
      3. Restaurant listings
      4. Restaurant detail
      5. Map tab
    3. Project setup
      1. Creating a new project
    4. Summary
  8. Setting Up the Basic Structure
    1. Starting from scratch
    2. Storyboard setup
      1. Adding our app assets
      2. Storyboards
        1. Creating our launch screen
        2. Adding a Navigation Controller
    3. Summary
  9. Building Our App Structure in Storyboard
    1. Adding a Collection View Controller
    2. Hooking up our outlets
    3. Creating a custom color
    4. Setting up our cell
    5. Section header
    6. Updating the grid
    7. Adding a modal
      1. Updating Bar Button Items
      2. Unwinding our Cancel button
      3. Adding our first Table View
    8. Summary
  10. Finishing Up Our App Structure in Storyboard
    1. Adding our Restaurant List View
    2. Hooking up our outlets
    3. Setting up our cell
    4. Adding Reviews View  
    5. Viewing reviews 
    6. Map Kit View
    7. Summary 
  11. Designing Cells
    1. Setting up the Explore header  
      1. Adding Auto Layout to the Explore header
      2. Setting up the Explore cell 
      3. Adding Auto Layout to the Explore cell 
    2. Setting up the Restaurant cell
      1. Adding Auto Layout to the Restaurant cell  
      2. Location cell 
    3. Summary
  12. Designing Static Tables
    1. Setting up cells 
    2. Creating our section headers
      1. Creating our address section
        1. Adding Auto Layout to the headers
      2. Photos section
        1. Adding Auto Layout to the photos section 
      3. Reviews section
        1. Adding Auto Layout to the Review cells 
        2. Updating the reservation times cells
        3. Reservation information
        4. Reservation header
    3. Summary
  13. Designing a Photo Filter and Review Form
    1. Setting up our View Controllers 
    2. Adding our Photo Filter View
      1. Adding Auto Layout for the Photo Filter View
      2. Creating the Photo Filter View cell
      3. Adding Auto Layout to our Photo Filter cell
    3. Creating reviews
      1. Setting up the Review storyboard
      2. Creating a Review form
      3. Updating the Review cells 
      4. Updating our first cell 
      5. Positioning UI elements 
      6. Adding Auto Layout for creating reviews
    4. Refactoring the storyboard 
      1. Creating a new storyboard for the Map tab
      2. Creating a new storyboard for the Explore tab
    5. Summary
  14. Getting Started with the Grid
    1. Understanding the Model View Controller architecture
      1. Getting familiar with the setup
      2. Classes and structures
    2. Controllers and classes
      1. Creating our controller
      2. Understanding Collection View controllers and Collection View cells
      3. Getting data into Collection View
      4. Understanding the data source
    3. Summary
  15. Getting Data into Our Grid
    1. Model
      1. ExploreData.plist
      2. ExploreItem.swift
      3. ExploreDataManager.swift
    2. Getting data
    3. Connecting to our cell
    4. Hooking up our UI with IBOutlets
    5. Restaurant listing
    6. Summary
  16. Getting Started with the List
    1. Creating our Location View Controller class
    2. Connecting our Table View with our Location View Controller
    3. Digging into our Table View code
    4. Adding the data source and delegate
    5. Adding locations to our Table View
    6. Creating our first property list (plist)
    7. Adding data to our property list
    8. Creating our location data manager
    9. Working with our data manager
    10. Creating folders
    11. Summary
  17. Where Are We?
    1. Setting up map annotations
      1. What is an MKAnnotation?
      2. Creating a restaurant annotation
      3. Creating our Map Data Manager  
      4. Creating a base class 
      5. Refactoring code 
        1. Refactoring ExploreDataManager
    2. Creating and adding annotations
      1. Creating our Map View Controller 
      2. Creating custom annotations
    3. Map to restaurant detail
      1. Creating a storyboard reference
      2. Map to restaurant detail
        1. Passing data to restaurant  detail
    4. Organizing your code
      1. Refactoring ExploreViewController
        1. Using the MARK  comment
        2. Refactoring RestaurantViewController
        3. Refactoring MapViewController
    5. Summary
  18. Working with an API
    1. Creating an API Manager
      1. What is an API?
      2. Understanding a JSON file
      3. Exploring the API Manager file
    2. Location list
      1. Selecting a location
      2. Adding a Header view
      3. Passing a selected location back to Explore View
      4. Unwinding our Done button
      5. Getting the last selected location
      6. Passing location and cuisine to the restaurant list
      7. Creating our restaurant cell class
        1. Setting up restaurant list cell outlets
        2. Creating a restaurant data manager
        3. Handling no data
    3. Summary 
  19. Displaying Data in Restaurant Detail
    1. Adding a navigation button 
    2. Displaying data in our static Table View
    3. Summary
  20. Foodie Reviews
    1. Getting started with reviews
    2. Displaying ratings in our custom UIControl
    3. Adding our touch events
    4. Setting up the unwind segues
    5. Setting up our rating control 
    6. Creating our review form controller 
    7. Summary 
  21. Working with Photo Filters
    1. Understanding filters 
    2. Creating our filter scroller 
      1. Creating a filter cell
      2. Creating our apply filter view controller
    3. Getting permission 
    4. Summary
  22. Understanding Core Data
    1. What is Core Data?
    2. Creating a data model 
      1. Entity auto-generation
      2. Restaurant Photo Entity
      3. Review item
      4. Core Data manager 
    3. Summary
  23. Saving Reviews
    1. Saving reviews 
    2. Saving photos 
    3. Setting up the cell UI 
    4. Adding Auto Layout
    5. Adding an overall rating 
    6. Summary 
  24. Universal
    1. Explore
    2. Location listing 
    3. Restaurant listing 
      1. Updating restaurant details 
    4. Summary
  25. iMessages
    1. Understanding iMessages
      1. Creating our extension  
      2. Updating our assets 
    2. Implementing our Messages UI 
      1. Adding Auto Layout to our  cell
    3. Creating a framework 
      1. Connecting our message cell 
    4. Showing restaurants 
      1. iMessage crashing 
      2. Sending reservations  
    5. Summary
  26. Notifications
    1. Starting with the basics 
      1. Getting permission 
      2. Setting up notifications 
      3. Showing notifications 
    2. Customizing our notifications
      1. Embedding images 
      2. Adding buttons
      3. Custom UI in notifications 
    3. Summary 
  27. Just a Peek
    1. Adding 3D Touch quick actions 
    2. Adding favorites 
      1. Creating a new model object  
    3. Updating our Core Data manager 
    4. Summary
  28. Drag and Drop
    1. Accepting drag from other apps 
    2. Dragging and dropping filter items 
    3. Summary
  29. SiriKit
    1. Understanding SiriKit
      1. Supported intents
      2. Enable Siri capabilities
      3. Creating users
      4. Updating our intent handler
      5. Testing Siri
    2. Summary
  30. Beta and Store Submission
    1. Creating a bundle identifier
    2. Creating a certificate signing request
    3. Creating production and development certificates
    4. Creating a production provisioning profile
    5. Creating a Development Provisioning Profile
    6. Creating an App Store listing
    7. Creating an archive build
    8. Internal and external testing
      1. Internal testing
      2. External testing
    9. Summary
  31. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think