Short description
Going beyond what's in the iPhone SDK, this guide shows Mac developers how to use it to create high-quality modular applications for the iPhone and iPod Touch by focusing on how to use modularity techniques and the unique abilities of the iPhone.
Long description
This book goes beyond what's in the iPhone SDK to show Mac developers how to use it to create secure, high quality, modular applications for the iPhone and iPod touch. By focusing on how to use modularity techniques and the unique abilities of the iPhone, this book shows Mac developers how to dramatically increase their productivity and reduce the effort required to create iPhone applications. By showing the user how to create non-web-based JavaScript applications, the barrier of entry for iPhone application creation is reduced for all developers, especially for those who come from a scripting language background or have no knowledge of Objective-C.
Review
Praise for Developing Hybrid Applications for the iPhone For those not ready to tackle the complexities of Objective-C, this is a great way to get started building iPhone apps. If you know the basics of HTML, JavaScript, and CSS, you'll be building apps in no time. --August Trometer, Owner of FoggyNoggin Software, www.foggynoggin.com Lee S. Barney takes the complexities of iPhone application creation and utilizes simple and often witty examples and language to make this book an enjoyable and useful read. It is not a simple how-to book, but if you have some web programming background and an idea, this book can provide you with the foundation for well-made, maintainable, and useable applications for the iPhone. --William Dalton This is an outstanding book! If you are interested in building applications for the iPhone, this is the book for you. Lee S. Barney makes it simple and easy to understand. He has you creating a custom application from the very first chapter. Then, he brings you up the learning curve until you're building applications with advanced iPhone features, such as the accelerometer, GPS, and embedded maps. This is an extremely well-written and easy-to-follow book. --Joey Skinner, CEO and President, Rodeo Software Lee S. Barney employs his solid background in JavaScript and Xcode to demonstrate useful techniques for building hybrid iPhone applications. I appreciate his candor as he shares some of the pitfalls that might trap newcomers, which then supports the direction for his solution. If you have a strong background in Javascript and are looking to break into iPhone application development, this book would make for a good segue. --A. Scott Mikolaitis
Table of contents
- Part I: Creating Hybrid iPhone Applications with JavaScript - Introduction - Hybrid application runs on the phone but is built in JavaScript - Hybrid applications are not mini web browsers - Hybrid applications use standard iPhone UI components - Tools and Modularity make hybrid application creation easy Chapter 1: Developing with Dashcode and Xcode Hybrid application creation makes use of both Dashcode and Xcode. Dashcode is used for creating the user interface and JavaScript creation, editing, and debugging, and Xcode is used for compiling, deploying, and executing the application on the device. This chapter discusses and gives examples of how these two tools can effectively be used together to develop hybrid applications without burdening the developer. - Introduction - Use Dashcode to - Create - Debug - Use Xcode to - Deploy - The Dashcode QChybrid custom application template - Forward reference to appendix B for installation - Component parts - Adding Dashcode library objects - Adding JavaScript code to handle events in the interface - The Xcode hybrid application template - Forward reference to appendix B for installation - Component parts - Objective-C iPhone application design - Delegates and Controllers - The application delegate - Explanation and code - The browser view controller - Explanation - Purpose - Rotation of the phone - Dialing phone numbers - source code example and description - forward reference to Chapter 7 Chapter 2: JavaScript Modularity in iPhone Applications This chapter shows the reader how to create and use modularity in JavaScript to quickly and easily create dynamic iPhone hybrid applications. - Modularity - What is modularity? - Tight cohesion - Loose coupling - Why modularity? - Eases development - Eases support - Division of labor - Business control functions in JavaScript - Purpose - Encapsulate decision making - Handles one or few decisions - Should data be retrieved? - What data should be retrieved? - Forward reference to Chapter 3 - Example - Retrieving user information - source code example and description - View control functions in JavaScript - Purpose - Encapsulate screen updating - Code becomes reusable for multiple commands - Handles updating one or more portions of the screen - Multiple VCF can be used for one command - Example - Displaying user information - source code example and description - Command -- response behavior. Linking BCF's and VCF's - Dispatching - One BCF per command - Multiple VCF's per command - Command validation - Validation must happen prior to dispatching to BCF's and VCF's - Multiple Validation functions per command - Default validation - Applies to all commands - Validation control functions - Encapsulate validation - Code becomes reusable for multiple commands - Example - Form field checking - Source code example and description Chapter 3: Using WebKits' Database This chapter shows how to store data on the iPhone from a JavaScript application using UIWebViews' built-in SQLite database. Readers will also see how to create data access objects to make the use of this database much easier. Full example code will be provided. - Accessing persistent local data - The database API - Database creation - Inside of JavaScript - By including a SQLite file in the project - Asynchronicity - What is asynchronicity? - Ex. Web page retrieval - Ex. AJAX calls - Forward reference to Chapter 4 - All calls to modify or retrieve data from the database are asynchronous - Executing queries - Select statements - The result set API - Inserting data - Insert statements - Determining the value of an auto-incrementing id - Success and failure indicators - Prepared statements - What are prepared statements - Why use prepared statements - Using prepared statements - Transactions - What are transactions - Why use transactions - Using transactions - Database access objects - What is a DAO - A module as discussed in Chapter 1 - Other access objects - Interface similar to Server Access Object -SAO - Forward reference to Chapter 4 - A proposed API - The getData method implementation - The setData method implementation - Defining and using Transactions with the DAO Chapter 4: Using Remote Data Securely This chapter shows how a standalone application can quickly and easily become Internet-aware using a server access object. This server access object wraps the use of the AJAX XMLHttpRequest object in an easy to use module. By using this module the reader will be able to leverage its' ease of use as well as its' security features with minimal effort. - Server Access Object makes asynchronous calls by default - Using a VCF as a callback function - The ServerAccessObject - API - Similar to the DAO API - Back reference to Chapter 3 - POSTing and GETting data - POST is more secure - GET is faster - Default in SAO is POST - Source code and explanation - The XMLHttpRequest object - API - Simple example - Handling errors - Storing and retrieving errors as they happen - Dispatching errors - Creating error control functions - Dispatching to the security functions - Creating security control functions - Multiple - Security control functions in JavaScript - Purpose - Encapsulate screen updating - Code becomes reusable for multiple commands - Handles data checking for one or more commands - Checks data as it returns from the server - Example - JSON data checker - Detects man in the middle attacks - Ensures that no JavaScript insertion attack is being performed - Source code example and description Part II: Creating an iPhone User Interface - Introduction - The iPhone has unique capabilities - Use them well and often - Be aware of CPU and memory limitations Chapter 5: Creating User Interfaces The iPhone, being a mobile device, has limited screen space. This chapter discusses and gives examples of how to create easy to use interfaces that follow the iPhone Human Interface Guidelines (HIG) without sacrificing creativity and application focus. - Why are there iPhone UI Guidelines? - Consistent User Experience - Feels like an iPhone app not a desktop app - Users more willing to download and use your app - Flattens users learning curve - Lowers user stress - Users can use your app with less effort - Application acceptance for distribution via the app store - Compliance with the iPhone HIG is one of the criteria for approval of your application for distribution - What are the iPhone Human Interface Guidelines? - Main application types - Utilities - Small amount of data - Two Screens of Content - Main display - For viewing - Back display - For editing - Productivity Applications - Larger amount of data - Hierarchically arranged displays - Immersion Applications - Simple Striking interface - Interactive Display - More than just games - Interface richness - iPhone users expect a rich media experience from all applications - Images - Backgrounds can be much more than plain colors - Icons - A well-designed icon can be the difference between a user adopting your application or using someone else's. - Consistent User Experience - Color scheme - Control object placement - Buttons, views, etc. - User actions - The desired user action must be obvious to a novice user - Application response to user interaction - Control objects of the same type should behave in the same fashion - Never surprise the user with a controls' behavior. - Immediate feedback given - Highlighting a selection - Moving to another screen - Using Dashcode to create the interface - Forward reference to appendix B for installation - Creating a hybrid utility application interface - Using the QChybrid utility template - Selection of project type - Modification within the readers project - Example and sample code - Creating a hybrid productivity application interface - Using the