Book Image

iOS Development using MonoTouch Cookbook

By : Dimitris Tavlikos
Book Image

iOS Development using MonoTouch Cookbook

By: Dimitris Tavlikos

Overview of this book

<p>MonoTouch brings the amazing revenue opportunities of Apple’s billion dollar app store to C# and .NET developers. <br /><br />This cookbook leaves no stone unturned, providing you with practical recipes covering user interfaces, data management, multimedia , web services, and localization, right through to application deployment on the app store.<br /><br />Whatever the area of MonoTouch iOS development you need to know about, you will find a recipe for it in this cookbook. Minimum theory and maximum practical action defines this book. It is jam packed with recipes for interacting with the device hardware, like the GPS, compass and the accelerometer. Recipes for those all important real world issues such as designing the UI with the integrated designer introduced with Xcode 4. It is the essential cookbook for C# and .NET developers wanting to be part of the exciting and lucrative world of iOS development.</p>
Table of Contents (22 chapters)
iOS Development Using MonoTouch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Technology is advancing quite rapidly. Portable devices, such as media players, smartphones, and tablets, have brought huge advancements and changes in the way people communicate, share, and consume digital content. Developers need to be up-to-date with the available platforms these devices work on, if they want to be "part of the game".

iOS, Apple’s operating system for its own portable devices, is undoubtedly one of the leading portable platforms today. If it weren’t for MonoTouch, .NET developers would have to spend time to learn a new programming language to expand their creativity to the iOS ecosystem.

This book, through a series of multiple recipes and with an almost equal number of complete projects, will help you become part of this ecosystem, with the help of MonoTouch and C#. When you finish reading it, you will be a capable iOS developer, ready to unleash your creativity to one of the most popular portable platforms today.

What this book covers

Chapter 1, Development Tools, will walk you through all the available IDEs and SDKs that you will need for using MonoTouch for iOS development. You will create your first MonoTouch project and learn how to debug on the simulator.

Chapter 2, User Interface: Views, introduces the concept of views and how they are part of a complete iOS application. Exploring a large number of various view components, you will create different applications that will help you understand how each component works.

Chapter 3, User Interface: View Controllers, discusses the Model-View-Controller (MVC) pattern and how to use it to create applications suitable for enhanced user experience. Through this chapter, you will also learn about the most useful controllers, which will be part of many of your projects in the future, and how to create iPad-specific and universal applications.

Chapter 4, Data Management, will walk you through a series of techniques that will allow you to incorporate data management in your applications. You will learn how to use SQLite databases, XML, LINQ-to-XML, and Serialization, formerly only available to .NET desktop and web projects.

Chapter 5, Displaying Data, expands on the available components to display data effectively on the smaller-than-desktop screens of iOS devices. You will get accustomed to using the UITableView for displaying lists of data, as well as the UIWebView for HTML (and more) content.

Chapter 6, Web Services, discusses creating applications that communicate online to exchange data. With the help of MonoTouch, you will not only learn how to use common .NET and WCF web services in iOS applications, but also how to read and parse JSON objects.

Chapter 7, Multimedia Resources, will teach you to create applications that capture, reproduce, and manage multimedia content through the device’s hardware. You will not only learn to use the camera to capture images and video, but also how to play back and record audio.

Chapter 8, Integrating iOS Features, will walk you through the ways to incorporate the platform’s native applications and components. You will learn how to provide e-mail, text messaging, and address book features in your application and how to use the native calendar to create events.

Chapter 9, Interacting with Device Hardware, discusses creating applications that are fully aware of their surrounding environment, through the device’s sensors. You will learn to adjust the user interface according to device orientations and how to respond to accelerometer and gyroscope events.

Chapter 10, Location Services and Maps, is a detailed guide for using the built-in location services to create applications that provide location information to the user. You will not only learn how to use the GPS hardware, but also how to display maps and layout information.

Chapter 11, Graphics and Animation, introduces 2D graphics and animation. You will learn to animate components and create simple graphics. By the end of this chapter, you will create a small finger-drawing application.

Chapter 12, Multitasking, will walk you through the details for implementing multitasking in iOS applications, which helps enhance user experience by executing code behind the scenes.

Chapter 13, Localization, discusses providing localized content in applications. You will learn how to prepare your application to target users worldwide.

Chapter 14, Deploying, will not only walk you through the required steps to deploy your finished application to devices, but also to prepare and distribute it to the App Store.

Chapter 15, iOS 5 Features, discusses some of the many new features that were introduced with the latest iOS version, such as page-curl content navigation, split keyboard for the iPad, and styling multiple views easily.

What you need for this book

The minimum requirement for this book is a Mac computer running Mac OS X Snow Leopard (10.6.*) or Lion (10.7.*). Almost all projects you will create with the help of this book work on the iOS Simulator. However, some projects will require a device to work correctly. You will find all the appropriate details in Chapter 1, Development Tools.

Who this book is for

This book is essential for C# and .NET developers with no previous experience in iOS development and Objective-C developers that want to make a transition to the benefits of MonoTouch and the C# language for creating complete, compelling iPhone, iPod, and iPad applications and deploying them to the App Store.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text are shown as follows: "Apple provides another base class, the UIViewController, which is responsible for managing views."

A block of code is set as follows:

public override void ViewDidLoad (){
  base.ViewDidLoad();
  this.myLabel.Text = "View loaded!";
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

public override void ViewDidLoad (){
  base.ViewDidLoad ();
  UIButton.Appearance.BackgroundColor = UIColor.Gray;
  UIButton.Appearance.SetTitleColor(UIColor.White, UIControlState.Normal);
  this.buttonPresent.TouchUpInside += delegate(object sender, EventArgs e) {
    this.PresentModalViewController(new ModalController(), true);
  } ;
}

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: " Any file that is marked as Content is being copied as-is in the application bundle".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt Publishing book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in the text or the code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted, and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt Publishing, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.