• Complain

T. Michael Rogers - Swift Recipes: A Problem-Solution Approach

Here you can read online T. Michael Rogers - Swift Recipes: A Problem-Solution Approach full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2015, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

T. Michael Rogers Swift Recipes: A Problem-Solution Approach
  • Book:
    Swift Recipes: A Problem-Solution Approach
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2015
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Swift Recipes: A Problem-Solution Approach: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Swift Recipes: A Problem-Solution Approach" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Swift Recipes provides a problem solution approach for dealing with key aspects of the Swift programming language (covering version 1.2), ensuring you have the indispensable reference you need to successfully execute common programming tasks. Youll learn how to use the unique features of the Swift programming language as well as its use with Cocoa and Cocoa touch frameworks and libraries.

Solutions are available for a range of problems, including application development with Xcode; working with strings, numbers, and object collections; dealing with threads, multi-core processing, and asynchronous processing; and building applications that take advantage of dates and timers and memory management.

This book is an essential core reference for every Swift programmer and offers solutions in a concise and easy-to-follow manner. T. Michael Rogers has developed iOS applications for Fortune 100 brands and startups, and has trained new and experienced iOS developers via the iOS Boot Camp in New York City, online courses, and in private settings. He brings his expertise to offer you the ability to use and exploit Swift to get the most out of all your projects for your app creations, whether you use iOS or Mac OS X.

What youll learn
  • What strings and arrays are, and how to use them
  • How to manage your data effectively
  • How to build and work with dictionaries, dates and times, timers, and localization
  • How to deal with threads, multi-core processing, and asynchronous processing
  • How to utilize Cocoa touch and Cocoa and core frameworks for user interfaces and experience design and development
  • How to access and work with iOS SDK for iPhone and iPad apps design and development
Who this book is for

This book is for experienced Apple iOS, Mac OS X and even Objective-C programmers who may be new to Swift programming language. Some Swift exposure is recommended.

Table of Contents

Chapter 1: Swift Programming

Chapter 2: Complex Types

Chapter 3: Collections

Chapter 4: Advanced Swift Programming

Chapter 5: iOS Applications

Chapter 6: OS X Applications

Chapter 7: Files and Directories

Chapter 8: Concurrency

Chapter 9: Web Services

Chapter 10: Core Data

Chapter 11: Advanced iOS 8 Features

T. Michael Rogers: author's other books


Who wrote Swift Recipes: A Problem-Solution Approach? Find out the surname, the name of the author of the book and a list of all author's works by series.

Swift Recipes: A Problem-Solution Approach — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Swift Recipes: A Problem-Solution Approach" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
T. Michael Rogers 2015
T. Michael Rogers Swift Recipes 10.1007/978-1-4842-0418-4_1
1. Swift Programming
T. Michael Rogers 1
(1)
CT, USA
Welcome to Swift Recipes . Swift, announced by Apple at WWDC 2014 and released in September of 2014 is a modern alternative to Objective-C for iOS and OS X developers. In each chapter of this book are recipes or solutions to common situations and challenges you will encounter when developering iOS and OS X applications.
Each chapter follows the same format. A problem is presented, followed by the solution. The solution is discussed in detail in a section named How It Works. This section explains the implementation of the solution using Swift. Code examples and details about how to apply the code are used to walk you through the solution. Finally, in The Code and Usage section, the full listing of the code is provided along with instructions on how to use the full listing.
This chapter will focus on essential recipes you will encounter in Swift. It will provide solutions to common situations you will encounter, such as
  • Getting Started with Swift
  • Installing Xcode 6
  • Working with Playgrounds
  • Designing User Interface Elements in a Storyboard
  • Dealing with Strings
  • Formatting Numbers as Strings
  • Getting the Length of a Swift String
  • Manipulating Swift Strings
  • Manipulating Strings with Native Swift Methods
  • Storing Strings on the iOS File System
  • Reading a Text File into a String
  • Reading and Writing Text Files in Cocoa
  • Dealing with Numbers
  • Dealing with Dates
Swift is still a young language. In many of the following recipes, you must use Foundation objects such as NSString and NSDate . Many swift classes are bridged to Foundation objects and can work together seamlessly. Recipes in this chapter leverage those bridged functions.
1.1 Getting Started with Swift
Problem
You have heard and read good things about Swift since it was released, but you are still wondering about the benefits of working with this new language.
Solution
Swift was created by Apple to provide the development community with a new modern programming language. Swift can be used independently or alongside Objective-C to create Mac OS and iOS applications. Swift does have a large number of modern features that Objective-C does not. Some key features of Swift that are missing in Objective-C are
  • Type Safety. Type safety helps developers avoid the problems inherent with Objective-C and its use of pointers. All types must have a default value. Variables cannot be nil, unless specified by the developer. An optional type variable may be nil or have a value. The keyword optional is used to define an optional variable.
  • Type Inference. Swift seeks to make coding more efficient, eliminating some of the artifacts that are present in many languages. The complier can determine the type of most variables using the initial value of the variable. This saves programming time and effort by eliminating the need to explicitly type variables in your code.
  • Enumerations and Structures. Both can have methods and properties, making them more powerful than ever.
  • Playgrounds. Playgrounds allow developers to write code in real time and see the results. Developers can code without creating a project, workspace or other typical project requirements. Common playground recipes are found later in this chapter.
1.2 Installing Xcode 6
Problem
You have not yet installed Xcode 6.
Solution
Use the Mac AppStore to install Xcode 6.
How It Works
In order to install Xcode 6, you must have a Mac running OS X Mavericks (10.9) or Yosemite. Launch the Mac App Store, and search for Xcode. Xcode can be downloaded for free from the Mac App Store (Figure ). Once there, click Get.
Figure 1-1 Click Install Xcode will download and install 13 Working - photo 1
Figure 1-1.
Click Install. Xcode will download and install
1.3 Working with Playgrounds
Problem
You want to quickly write some code to explore an idea.
Solution
Xcode 6 and Swift have a new feature called playgrounds . Playgrounds let you write code and the playground immediately compiles and executes it. This lets you test an idea without having to create a new project or work within your existing project.
How It Works
Your first step is to launch Xcode. To create a new playground, select File New Playground. Provide a name for your playground and for this recipe, choose iOS as the platform. Next click continue, and then select a location for your saved playground file (Figure ).
Figure 1-2 Select New from the file menu and then select Playground in the - photo 2
Figure 1-2.
Select New from the file menu and then select Playground in the submenu
Xcode will open a playground window containing sample code. A playground window consists of these areas: the code area on the left, the results sidebar on the right, and the Assistant Editor, which is hidden by default. To see the Assistant Editor, select View Show Toolbar. Then click the assistant editor icon that looks like a tuxedo. This will open the Assistant Editor to the right of the results sidebar (Figure ).
Figure 1-3 The Playground window The Code and Usage Working with a - photo 3
Figure 1-3.
The Playground window
The Code and Usage
Working with a playground is designed to be easy. Start writing code in the code editor. Begin with the sample code that Apple has provided:
// Playground - noun: a place where people can play
import UIKit
var str = "Hello, playground"
The first line is a comment, the second line imports the UIKit framework so that you can access those APIs if you wish, and finally the third line creates a new string variable. If you look, on the same line as the string declaration, in the results sidebar, you will see Hello, playground. This is the evaluation of the statement var str = "Hello, playground" . The result of that expression is the string Hello, playground.
Add a new variable called welcome and assign it a value such as this one:
var welcome = "Welcome, playground"
The playground will quickly evaluate that statement and display the results on the right column of the window. You will see additional uses for playgrounds in coming recipes.
1.4 Designing User Interface Elements in a Storyboard
Problem
You need to design a user interface element, but you dont want to compile and run an application to do so.
Solution
Playgrounds provide visualization tools that will display UI objects as they would appear in a real application.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Swift Recipes: A Problem-Solution Approach»

Look at similar books to Swift Recipes: A Problem-Solution Approach. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Swift Recipes: A Problem-Solution Approach»

Discussion, reviews of the book Swift Recipes: A Problem-Solution Approach and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.