Swift OS X Programming for Absolute Beginners

Book description

Swift OS X Programming for Absolute Beginners is your step-by-step guide to learning how to code using Swift, Apple's hottest new programming language. This book will not only teach complete programming novices how to write OS X programs, but it can also help experienced programmers moving to the Macintosh for the first time. You will learn to understand the principles of programming, how to use Swift and Xcode, and how to combine your knowledge into writing OS X programs.

If you've always wanted to learn coding but felt stymied by the limitation of simplistic programming languages or intimidated by professional but complicated programming languages, then you'll want to learn Swift. Swift is your gateway to both Macintosh and iOS app development while being powerful and easy to learn at the same time, and Swift OS X Programming for Absolute Beginners is the perfect place to start - add it to your library today.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. About the Techincal reviewer
  9. Acknowledgments
  10. Introduction
  11. Chapter 1 : Understanding Programming
    1. Programming Principles
    2. Structured Programming
    3. Event-Driven Programming
    4. Object-Oriented Programming
      1. Encapsulation
      2. Inheritance
      3. Polymorphism
    5. Understanding Programming Languages
    6. The Cocoa Framework
    7. The View-Model-Controller Design
    8. How Programmers Work
    9. Summary
  12. Chapter 2 : Getting to Know Xcode
    1. Giving Commands to Xcode
    2. Modifying the Xcode Window
    3. Creating and Managing Files
    4. Creating and Customizing a User Interface
    5. The Standard and Assistant Editors
    6. Running a Program
    7. Summary
  13. Chapter 3 : The Basics of Creating a Mac Program
    1. Creating a Project
    2. Designing a User Interface
    3. Using the Document Outline and Connections Inspector
    4. Summary
  14. Chapter 4 : Getting Help
    1. Understanding the Cocoa Framework
    2. Looking Up Properties and Methods in a Class File
      1. Looking Up Class Files with the Help Menu
      2. Looking Up Class Files with Quick Help
    3. Browsing the Documentation
    4. Searching the Documentation
    5. Using Code Completion
    6. Understanding How OS X Programs Work
    7. Summary
  15. Chapter 5 : Learning Swift
    1. Using Playgrounds
      1. Creating Comments in Swift
      2. Storing Data in Swift
    2. Typealiases
    3. Using Unicode Characters as Names
    4. Converting Data Types
    5. Computed Properties
    6. Using Optional Variables
    7. Linking Swift Code to a User Interface
    8. Summary
  16. Chapter 6 : Manipulating Numbers and Strings
    1. Using Mathematical Operators
      1. Prefix and Postfix Operators
      2. Compound Assignment Operators
    2. Using Math Functions
      1. Rounding Functions
      2. Calculation Functions
      3. Trigonometry Functions
      4. Exponential Functions
      5. Logarithmic Functions
    3. Using String Functions
    4. Creating Functions
      1. Simple Functions Without Parameters or Return Values
      2. Simple Functions With Parameters
      3. Functions With Parameters That Return Values
      4. Defining External Parameter Names
      5. Using Variable Parameters
      6. Using Inout Parameters
      7. Understanding IBAction Methods
    5. Summary
  17. Chapter 7 : Making Decisions with Branches
    1. Understanding Comparison Operators
    2. Understanding Logical Operators
    3. The if Statement
    4. The if-else Statement
    5. The if-else if Statement
    6. The switch Statement
    7. Using the switch Statement with enum Data Structures
    8. Making Decisions in an OS X Program
    9. Summary
  18. Chapter 8 : Repeating Code with Loops
    1. The while Loop
    2. The repeat-while Loop
    3. The for Loop That Counts
    4. The for-in Statement
    5. Exiting Loops Prematurely
    6. Using Loops in an OS X Program
    7. Summary
  19. Chapter 9 : Arrays and Dictionaries
    1. Using Arrays
      1. Adding Items to an Array
      2. Deleting Items From an Array
      3. Querying Arrays
      4. Manipulating Arrays
    2. Using Dictionaries
      1. Adding Items to a Dictionary
      2. Retrieving and Updating Data in a Dictionary
      3. Deleting Data in a Dictionary
      4. Querying a Dictionary
    3. Using Dictionaries in an OS X Program
    4. Summary
  20. Chapter 10 : Tuples, Sets, and Structures
    1. Using Tuples
      1. Accessing Data in a Tuple
    2. Using Sets
      1. Creating a Set
      2. Adding and Removing Items from a Set
      3. Querying a Set
      4. Manipulating Sets
    3. Using Structures
      1. Storing and Retrieving Items from a Structure
    4. Using Structures in an OS X Program
    5. Summary
  21. Chapter 11 : Creating Classes and Objects
    1. Creating Classes
      1. Accessing Properties in an Object
      2. Computed Properties in an Object
      3. Setting Other Properties
      4. Using Property Observers
    2. Creating Methods
    3. Using Objects in an OS X Program
    4. Summary
  22. Chapter 12 : Inheritance, Polymorphism, and Extending Classes
    1. Understanding Inheritance
      1. Understanding Polymorphism
      2. Overriding Properties
      3. Preventing Polymorphism
    2. Using Extensions
    3. Using Protocols
      1. Defining Optional Methods and Properties in Protocols
      2. Using Inheritance with Protocols
    4. Using Delegates
    5. Using Inheritance in an OS X Program
    6. Summary
  23. Chapter 13 : Creating a User Interface
    1. Understanding User Interface Files
    2. Searching the Object Library
      1. User Interface Items That Display and Accept Text
      2. User Interface Items That Restrict Choices
      3. User Interface Items That Accept Commands
      4. User Interface Items That Groups Items
    3. Using Constraints in Auto Layout
      1. Defining Window Sizes
      2. Placing Constraints on User Interface Items
      3. Editing Constraints
    4. Defining Constraints in an OS X Program
    5. Summary
  24. Chapter 14 : Working with Views and Storyboards
    1. Creating User Interface Files
      1. Adding an .xib or .storyboard File
    2. Defining the Main User Interface
    3. Displaying Multiple .xib Files
    4. Using Storyboards
      1. Zooming In and Out of a Storyboard
      2. Adding Scenes to a Storyboard
      3. Defining the Initial Scene in a Storyboard
      4. Connecting Scenes with Segues
      5. Displaying Scenes From a Segue
      6. Removing a Scene After a Segue
      7. Passing Data Between Scenes
    5. Summary
  25. Chapter 15 : Choosing Commands with Buttons
    1. Modifying Text on a Button
    2. Adding Images and Sounds to a Button
    3. Connecting Multiple User Interface Items to IBAction Methods
    4. Working with Pop-Up Buttons
      1. Modifying Pop-Up Menu Items Visually
      2. Adding Pop-Up Menu Items with Swift Code
    5. Summary
  26. Chapter 16 : Making Choices with Radio Buttons, Check Boxes, Date Pickers, and Sliders
    1. Using Check Boxes
    2. Using Radio Buttons
    3. Using a Date Picker
    4. Using Sliders
    5. Summary
  27. Chapter 17 : Using Text with Labels, Text Fields, and Combo Boxes
    1. Using Text Fields
      1. Using a Number Formatter
      2. Using a Secure Text Field, a Search Field, and a Token Field
    2. Using Combo Boxes
      1. Creating an Internal List
      2. Using a Data Source
    3. Summary
  28. Chapter 18 : Using Alerts and Panels
    1. Using Alerts
      1. Getting Feedback from an Alert
      2. Displaying Alerts as Sheets
    2. Using Panels
      1. Creating an Open Panel
      2. Creating a Save Panel
    3. Summary
  29. Chapter 19 : Creating Pull-Down Menus
    1. Editing Pull-Down Menus
      1. Adding New Pull-Down Menu Titles to the Menu Bar
      2. Adding New Commands to a Pull-Down Menu
      3. Editing Commands
      4. Connecting Menu Commands to Swift Code
    2. Summary
  30. Chapter 20 : Protocol-Oriented Programming
    1. Understanding Protocols
      1. Using Methods in Protocols
      2. Adopting Multiple Protocols
      3. Protocol Extensions
      4. Using Protocol Extensions to Extend Common Data Types
    2. Summary
  31. Chapter 21 : Defensive Programming
    1. Test with Extreme Values
    2. Be Careful with Language Shortcuts
    3. Working with Optional Variables
    4. Working with Optional Chaining
    5. Error Handling
      1. Defining Errors with enum and ErrorType
      2. Creating a Function to Identify Errors
      3. Handling the Error
    6. Summary
  32. Chapter 22 : Simplifying User Interface Design
    1. Using Stack View
    2. Fixing Constraint Conflicts
    3. Working with Storyboard References
    4. Summary
  33. Chapter 23 : Debugging Your Programs
    1. Simple Debugging Techniques
    2. Using the Xcode Debugger
      1. Using Breakpoints
      2. Stepping Through Code
      3. Managing Breakpoints
      4. Using Symbolic Breakpoints
      5. Using Conditional Breakpoints
    3. Troubleshooting Breakpoints in Xcode
    4. Summary
  34. Chapter 24 : Planning a Program Before and After Coding
    1. Identifying the Purpose of Your Program
    2. Designing the Structure of a Program
    3. Designing the User Interface of a Program
      1. Design a User Interface with Paper and Pencil
      2. Design a User Interface with Software
    4. Marketing Your Software
      1. Blogging About Your Software
      2. Giving Away Free Software
      3. Posting Videos About Your Software
      4. Give Away Free Information
      5. Join Social Networks
    5. Summary
  35. Index

Product information

  • Title: Swift OS X Programming for Absolute Beginners
  • Author(s):
  • Release date: August 2015
  • Publisher(s): Apress
  • ISBN: 9781484212332