Apress Migrating to Swift from Android (2014).pdf

(7077 KB) Pobierz
Make the jump to iOS development using
Apple’s Swift programming language
Swift
from
Android
Sean Liao
Migrating
to
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a
Glance
About the Author �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
ix
About the Technical Reviewer �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xi
Acknowledgments �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xiii
Introduction �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xv
Part I : Prepare Your Tools �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
1
Chapter 1: Setting Up the Development Environment �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
3
Chapter 2: iOS Programming Basics �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
11
Part II: A Roadmap for Porting �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
45
Chapter 3: Structure Your App �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
47
Chapter 4: Implement Piece by Piece �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
117
Part III: Pulling It All Together �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
185
Chapter 5: Recap with a Case Study �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
187
Index �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
245
iii
Introduction
In 2000, I started my first PalmOS mobile app for an inventory-tracking project.
The initial project was a full-staffed team effort that consisted of mobile
developers, SAP consultants, supply-chain subject matter experts, middleware
developers, QA testers, architects, business sponsors, and so forth. JavaME
came up strong in 2002, followed by Pocket PC/Windows Mobile. I did several
mobile projects in which I converted mobile apps to the Pocket PC platform by
blindly translating JavaME code to C# .NETCF mobile code. These “translation”
efforts prolonged the whole product life cycle. The project achieved higher ROI
as the product life extended, because the extra cost of translating mobile code
was surprisingly low. Ever since then, I have been translating front-end mobile
apps among JavaME, BlackBerry, and Windows Mobile platforms.
In early 2009, by repeating the same porting process, I created my first iOS
app by translating a Windows mobile app. That started my iOS programming
journey, and later it was a no-brainer for me to try porting to Android. Most
mobile apps are platform agnostic. When you have the whole solution
completed for either iOS or Android, all the business and technical issues
have been verified and the other deliverables and project artifacts are already
reusable. It would be a waste not to port it to the other platform. Earlier this
year, I wrote my first book,
Migrating to Android for iOS Developers,
to share my
beliefs and experiences. After Swift was introduced at Worldwide Developers
Conference (WWDC) 2014, I decided to write this book because the similarity
between Java and Swift makes the porting method even easier while the same
ROI analysis remains true.
The primary objective of this book is to help experienced Android developers
leap into native iOS–Swift mobile development. It is easier than you think,
and this book will make it even easier with Android analogies and mapping
guidelines. You can immediately translate common mobile use cases to iOS.
xv
xvi
Introduction
Who Is This Book For?
This book is specifically written for Android developers who want to take
advantage of their mobile knowledge and make mobile applications available
on the iOS mobile platform. The book will show you the common iOS
programming subjects and frameworks using your familiar Android vocabularies
without lengthy explanations, because you already know these mobile subjects
from being an Android developer.
How This Book Is Organized
In Part I, you will get the iOS Xcode integrated development environment (IDE)
up and running in no time. You will be guided in creating tutorial projects that
will become your porting sample projects. I believe this is the best way for you
to get hands-on experience while learning programming topics.
Part II of this book shows you how to plan and structure your iOS apps: by
creating a storyboard and breaking the app into model-view-controller (MVC)
classes. You will be able to reuse most of the existing software artifacts and
design the rest from their Android counterparts. The common mobile topics are
followed, including user interface, managing data, and networking with remote
services. After you finish Part II, you will be able to create simple but meaningful
iOS apps with rich UI components, and to handle common CRUD (create, read,
update, delete) operations locally and remotely.
Last, Part III walks you through a case study that ports a complete iOS app to
Android. It recaps how to use mapping guidelines from the topics in Part II. You
can also use the book’s table of contents to help find the porting guidelines as
needed.
When you complete this journey, you will be able to use Xcode and Swift to
effectively port your existing Android apps to iOS.
Zgłoś jeśli naruszono regulamin