• Complain

David Mark - Beginning iPhone development with Swift : exploring the iOS SDK

Here you can read online David Mark - Beginning iPhone development with Swift : exploring the iOS SDK full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: New York, N.Y, year: 2014, 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.

David Mark Beginning iPhone development with Swift : exploring the iOS SDK

Beginning iPhone development with Swift : exploring the iOS SDK: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Beginning iPhone development with Swift : exploring the iOS SDK" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

The team that brought you the bestselling Beginning iPhone Development, the book that taught the world how to program on the iPhone, is back again for Beginning iPhone Development with Swift. This definitive guide to the Swift programming language and the iOS 8 SDK, and the source code has been updated to reflect Xcode 6.3.1 and Swift 1.2.

Theres coverage of brand-new technologies, including Swift playgrounds, as well as significant updates to existing material. Youll have everything you need to create your very own apps for the latest iOS devices. Every single sample app in the book has been rebuilt from scratch using the latest Xcode and the latest 64-bit iOS 8-specific project templates, and designed to take advantage of the latest Xcode features.

Assuming little or no working knowledge of the new Swift programming language, and written in a friendly, easy-to-follow style, this book offers a complete soup-to-nuts course in iPhone, iPad, and iPod touch programming. The book starts with the basics, walking through the process of downloading and installing Xcode and the iOS 8 SDK, and then guides you though the creation of your first simple application.

From there, youll learn how to integrate all the interface elements iOS users have come to know and love, such as buttons, switches, pickers, toolbars, and sliders. Youll master a variety of design patterns, from the simplest single view to complex hierarchical drill-downs. The art of table building will be demystified, and youll learn how to save your data using the iPhone file system. Youll also learn how to save and retrieve your data using a variety of persistence techniques, including Core Data and SQLite. And theres much more!

What youll learn
  • Everything you need to know to develop your own bestselling iPhone and iPad apps
  • Utilizing Swift playgrounds
  • Best practices for optimizing your code and delivering great user experiences
  • What data persistence is, and why its important
  • Get started with building cool, crisp user interfaces
  • How to display data in Table Views
  • How to draw to the screen using Core Graphics
  • How to use iOS sensor capabilities to map your world
  • How to get your app to work with iCloud and more
Who this book is for

This book is for aspiring iPhone app developers, new to the Apple Swift programming language and/or the iOS SDK.

Table of Contents1. Welcome to the Swift Jungle

2. Appeasing the Tiki Gods

3. Handling Basic Interaction

4. More User Interface Fun

5. Rotation and Adaptive Layout

6. Multiview Applications

7. Tab Bars and Pickers

8. Introduction to Table Views

9. Navigation Controllers and Table Views

10. Collection Views

11. iPad Considerations

12. Application Settings and User Defaults

13. Basic Data Persistence

14. Hey! You! Get onto iCloud!

15. Grand Central Dispatch, Background Processing, and You

16. Core Graphics: Drawing with Quartz

17. Getting Started with Sprite Kit

18. Taps, Touches, and Gestures

19. Where Am I? Finding Your Way with Core Location and Map Kit

20. Whee! Gyro and Accelerometer!

21. The Camera and Photo Library

22. Application Localization

23. Appendix: A Swift Introduction to Swift

David Mark: author's other books


Who wrote Beginning iPhone development with Swift : exploring the iOS SDK? Find out the surname, the name of the author of the book and a list of all author's works by series.

Beginning iPhone development with Swift : exploring the iOS SDK — 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 "Beginning iPhone development with Swift : exploring the iOS SDK" 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

Appendix A

A Swift Introduction to Swift

Until recently, writing an iPhone or iPad application meant working with Objective-C. Because of its unusual (some would say elegant) syntax, Objective-C. With that understanding, lets get started right away!

Swift Basics

One of the best new features of Xcode 6 is the playground. As the name suggests, a playground is a place where you can go to play with code without having to create an environment in which to run itjust open a playground, type in some code, and see the results. Playgrounds are a great place to prototype something new and they are also an ideal place to start learning a new language, so were going to use them throughout this appendix.

Lets begin by creating a new playground. Start Xcode and go to FilePicture 1NewPicture 2Playground. In the dialog that opens, choose a name for your playground (something like SwiftBasics) and make sure that the Platform is iOS, and then press Next. Choose the folder in which your playground will be saved and then press Create. Xcode creates the playground and opens it in a new window, as shown in . As you read through the examples in this appendix, feel free to experiment by adding code of your own to the playground or by modifying the examples to see what happens.

Our newly created playground Playgrounds Comments Variables and Constants - photo 3

. Our newly created playground

Playgrounds, Comments, Variables, and Constants

Lets take a moment to look at what weve got in our playground. As you can see, its divided into two areascode on the left and results on the right. As you type code, the Swift compiler compiles and executes it, and shows you the result almost immediately. The code in declares a new variable called str and initializes it with the string "Hello, playground". You can see this string in the results column on the right. Try changing the value and notice that the result updates to match as soon as you stop typing.

The code on line 1 in is a comment. Anything following the character sequence // up to the end of the line is ignored by the compiler. Here, the comment occupies the whole line, but thats not necessary. We could add a comment to the end of a line of code too:

var str = "Hello, world" // K&R would be proud

To write a comment thats longer than one line, start it with /* and end it with */ , like this:

/*
This is a comment that occupies
More than one line.
*/

There are various different ways to write a multiline comment. Some people like to make it clear that a line is part of a comment by starting each line with a * character:

/*
* This is a comment that occupies
* More than one line.
*/

Other people like to write single-line comments like this:

/* This is another way to write a single-line comment. */

The import statement on line 3 makes Apples UIKit framework available for use in the playground:

import UIKit

IOS has many frameworks, some of which youll read about in this book. UIKit is the user interface framework, which well use in all of our code examples. Another framework that youll frequently make use of is Foundation, which contains classes that provide basic functionality like date and time handling, collections, file management, networking, and much more. To get access to this framework, you need to import it, like this:

import Foundation

However, UIKit automatically imports Foundation, so any playground that imports UIKit gets access to Foundation for free, without having to add an explicit import for it.

Line 5 is the first (and only) line of executable code in this playground:

var str = "Hello, playground"

The var keyword declares a new variable with a given name. Here, the variable is called str , which is appropriate because its a string. Swift is very liberal with variable names: you can use almost any character you like in the name, with the exception of the first character, which is somewhat restricted. You can find the precise rules in Apples documentation at https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language .

Following the declaration of the variable comes an expression that assigns its initial value. You dont have to initialize a variable when you declare it, but you must do so before you use it (i.e., before you execute any code that reads its value). However, if you do, then Swift can infer the variables type, saving you the trouble of stating it explicitly. In this example, Swift infers that str is a string variable, because you have initialized it with a string literal. If you choose not to provide an initializer (perhaps because there is no fixed initial value), you must declare the variables type by appending it to the name and separated from it by a colon, like this:

var str: String

Try changing the code on line 5 of the playground to this:

var str: String
str = "Hello, playground"

This is completely equivalent to the original code, but now youve had to explicitly state that str is a string variable ( String is the Swift type that represents a string). In most cases, its easier to combine the declaration and initialization, and allow the compiler to infer the variables type.

Heres another example that makes use of Swifts type inference feature:

var count = 2

Here, the compiler infers that the count variable is an integer. Its actual type is Int (well cover the numeric types.

Getting the inferred type of a variable The fact that you dont declare the - photo 4

. Getting the inferred type of a variable

The fact that you dont declare the type of a variable doesnt mean that it doesnt have one, or that you can play fast and loose with it. Swift assigns a type when the variable is declared and then you have to stick with that type. Unlike dynamic languages like JavaScript, you cant change the type of a variable simply by assigning a new value to it. Try doing this:

var count = 2
count = "Two"

Attempting to assign a string value to an integer variable is an error; youll see a red marker in the margin on the left of the playground. Click it, and Swift displays a message explaining the problem (see ).

Swift is not a dynamic language You cant change the type of a variable This - photo 5

. Swift is not a dynamic language. You cant change the type of a variable

This error message is not particularly clear. In fact, at the time of writing, Swift error messages can sometimes be a little hard to understand, but you can expect this to improve with later releases of Xcode.

Youve probably noticed that we arent bothering to add semicolons at the end of our statements. Thats one of the many nice little features of Swift: its almost never necessary to end a statement with a semicolon. If youre used to writing in C, C++, Objective-C or Java, that will probably feel a bit strange at first, but after a while, youll get used to it. Of course, you can type the semicolon if you want to, but most likely youll wind up not doing so. The only time you must use a semicolon is if you want to write two statements on the same line. This code is not valid:

var count = 2 count = 3

Add a semicolon, and the compiler is happy again:

var count = 2; count = 3

As the preceding line of code shows, you can change the value of a variable. Thats why its called a variable, after all. What if you just want to give a name to a fixed value? In other words, you want to create a constant and give it a name. For that, Swift provides the let statement. Syntactically, let is just like var , except that you must provide an initial value:

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Beginning iPhone development with Swift : exploring the iOS SDK»

Look at similar books to Beginning iPhone development with Swift : exploring the iOS SDK. 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 «Beginning iPhone development with Swift : exploring the iOS SDK»

Discussion, reviews of the book Beginning iPhone development with Swift : exploring the iOS SDK 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.