Datasheet

4
CHAPTER 1 INTRODUCTION TO IPHONE DEVELOPMENT WITH MONOTOUCH FOR C# DEVELOPERS
.NET layer over the native iPhone programming layer present on the iPhone OS, referred to as Cocoa
Touch. Cocoa Touch is based on the Cocoa layer in the Mac OS X and is available on the iPhone, iPod
Touch, and the iPad. MonoTouch does not provide a mechanism to cross-compile Windows Forms
applications, but allows developers to build applications that run natively on the iPhone.
Overall, the application programming interface (API) exposed by the MonoTouch SDK is a com-
bination of the .NET 2.0 Framework’s core features, the Silverlight 2.0 API, and the APIs on
the iPhone. MonoTouch provides a bridge (interop) between the iPhone’s native APIs based on
Objective-C and C-based APIs to the .NET world that C# developers are accustomed to.
MonoTouch Components
MonoTouch is made up of the following four components:
The
Monotouch.dll is a C# assembly that provides a binding API into the iPhone’s native APIs.
A command-line tool that compiles C# and Common Intermediate Language (CIL) code.
This compiled code can then be run in the simulator or an actual iPhone.
An add-in to MonoDevelop that allows for iPhone development and for Interface Builder to
create graphical applications.
A commercial license of the Mono runtime, which allows for the static linking of the Mono
runtime with the code developed.
Namespaces and Classes
MonoTouch provides a rich set of namespaces and classes to support building applications for the
iPhone. Some of the most popular namespaces and classes are:
MonoTouch.ObjCRuntime:
This namespace provides the interop/bridge between the
.NET/C# world and the Objective-C world of the iPhone.
MonoTouch.Foundation:
This namespace provides support for the data types necessary to
communicate with the Objective-C world of the iPhone. Most types are directly mapped. For
example, the
NSObject Objective-C base class is mapped to the MonoTouch.Foundation
.NSObject
class in C#. Some classes are not directly mapped and are instead mapped to their
native .NET types. For example,
NSString maps to the basic string type and NSArray maps
to a strongly typed array.
MonoTouch.UIKit:
This namespace provides a direct mapping between the UI components
within Cocoa Touch. The mapping is done by providing .NET classes for each UI compo-
nent, and this is the namespace that developers will likely spend most of their time working
with. For .NET developers, Cocoa Touch is an abstraction layer or API for building pro-
grams that run in the iPhone. Cocoa Touch is based on the Cocoa API used in building pro-
grams that run on the Mac OS X operating system. Cocoa Touch can be thought of as Cocoa
tuned for the touch-based iPhone operating system.
637821c01.indd 4637821c01.indd 4 5/27/10 5:29:36 PM5/27/10 5:29:36 PM