Learn swift on the mac

Page 243

viii

Contents

Quick Tour of Swift ����������������������������������������������������������������������������������������������������������� 9 Basic Types ��������������������������������������������������������������������������������������������������������������������������������������������� 9 Aggregate Types ����������������������������������������������������������������������������������������������������������������������������������� 10 Control Flow ����������������������������������������������������������������������������������������������������������������������������������������� 10 Functions ���������������������������������������������������������������������������������������������������������������������������������������������� 11 Objects �������������������������������������������������������������������������������������������������������������������������������������������������� 11 Generics ������������������������������������������������������������������������������������������������������������������������������������������������ 12 Getting the Sample Code ���������������������������������������������������������������������������������������������������������������������� 12

Summary ������������������������������������������������������������������������������������������������������������������������ 13 ■■Chapter 2: The Swift Playground in Xcode 6 ������������������������������������������������������� 15 Getting Started with a Playgorund ��������������������������������������������������������������������������������� 15 Custom QuickLook Plugins ��������������������������������������������������������������������������������������������� 20 XCShowView ����������������������������������������������������������������������������������������������������������������������������������������� 20 XCCaptureValue ������������������������������������������������������������������������������������������������������������������������������������ 21 XCPSetExecutionShouldContinueIndefinitely ���������������������������������������������������������������������������������������� 21

Custom Modules for Playground ������������������������������������������������������������������������������������ 21 Importing Your Code ���������������������������������������������������������������������������������������������������������������������������� 22

Summary ������������������������������������������������������������������������������������������������������������������������ 27 ■■Chapter 3: Accessing Swift’s Compiler and Interpreter: REPL ���������������������������� 29 What is REPL? ���������������������������������������������������������������������������������������������������������������� 29 LLDB and the Swift REPL ����������������������������������������������������������������������������������������������� 31 Summary ������������������������������������������������������������������������������������������������������������������������ 32 ■■Chapter 4: Introduction to Object-Oriented Programming ���������������������������������� 33 The Concept Behind OOP ����������������������������������������������������������������������������������������������� 34 Indirection and Variables ������������������������������������������������������������������������������������������������ 34 Procedural Programming ����������������������������������������������������������������������������������������������� 35 Objected Oriented Implementation ��������������������������������������������������������������������������������� 38 Summary ������������������������������������������������������������������������������������������������������������������������ 42


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.