C# On The iPhone with MonoTouch at DDD8

1,974 views
1,884 views

Published on

Slides from my MonoTouch session at DDD8, Reading, UK from 30th January 2010. Very similar slides to the ones from my Italian conference slides but slightly updated (to include iPad bits).

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,974
On SlideShare
0
From Embeds
0
Number of Embeds
163
Actions
Shares
0
Downloads
32
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

C# On The iPhone with MonoTouch at DDD8

  1. 1. C# on the iPhone with MonoTouch Chris Hardy follow on Twitter - @chrisntr
  2. 2. http://greatfridays.com
  3. 3. Covering... • What is MonoTouch? • How does it work? • Why would you use it? • Demos
  4. 4. Starting point....
  5. 5. Objective C and Xcode
  6. 6. Learn to read Objective-C
  7. 7. Learn to read Objective-C • All Apple documentation is in Obj-C • Most examples are in Obj-C • It’s not too hard to understand • It might even be fun...
  8. 8. What is MonoTouch?
  9. 9. What is Mono?
  10. 10. What is Mono? Open Source .Net Implementation of the Microsoft .Net Framework
  11. 11. Mono’s JIT Engine Memory Mono CIL
  12. 12. Apple No No... • Contractual Requirements • No interpreted code • No shared libraries • Kernel Limitations • iPhone OS 2.0+ disables JIT
  13. 13. Mono’s AOT Engine Native Code Mono AOT Mono Runtime CIL ARM
  14. 14. Monotouch Features • mtouch • MonoDevelop iPhone Add-In • CocoaTouch.NET • Full static AOT compiler • Support for all your existing code • Reflection • Generics • LINQ • Anonymous Methods • Lambda’s etc...
  15. 15. MonoTouch’s APIs
  16. 16. The Bindings • MonoTouch namespace • MonoTouch.Foo namespace • Maps to CocoaTouch’s Foo Framework • 1:1 Mapping of classes. • MonoTouch.UIKit.UILabel • CocoaTouch’s UIKit framework, UILabel class
  17. 17. Strong Types • Objective-C • Arrays are weakly typed: • NSArray return values. • MonoTouch has strong types • UIView[] Subviews { get; } • vs • NSArray *subviews; • Intellisense - explore the API...
  18. 18. Garbage Collection • Automatic: • Mono’s GC will collect objects on demand • Deterministic: • Use when you need control. • Every object in MonoTouch implements IDisposable using (var image = UIImage.FromFile(“foo.png”)){ surface.DrawImage(image, 20, 20); }
  19. 19. Linker
  20. 20. What about App Size? • 10 MB (compressed) limit on 3G/Edge downloads • .Net BCL and other libraries are huge • Mono Linker to the rescue!
  21. 21. Linking Assemblies
  22. 22. Linker Options • No Link • Link SDK Only • Full Link
  23. 23. Pipeline • Interface Builder GUI Designer • Exact same tool used by Xcode • Support for existing Xcode interfaces • MonoDevelop IDE
  24. 24. Integration • Tight integration between MD and IB • IB produces XIBs with MD parses • Automatic class generation in MD • Generates partial classes for all types, outlets and actions defined in Interface Builder
  25. 25. Outlets • Instance Variables • Can be strong or loosely typed • MD will strong type
  26. 26. Actions • Objects emit broadcast messages to receivers • You can do this C# • MonoDevelop takes care of the details for you • Creates partial methods for you extend
  27. 27. MonoTouch Events • Supports Objective-C pattern: webView.Delegate = new MyWebViewDelegate(); • C# style events as well: webView.PageLoaded += delegate { HideSpinningWheel(); }
  28. 28. Debugging • Console.WriteLine(“Debugging inside of MonoTouch”); • printf(“I made it to this line!n”)
  29. 29. Well... • MonoTouch released around 15th September 2009 • MonoTouch 1.1 on 2nd October 2009 • MonoTouch 1.2 (Beta) released on 28th October 2009... With Debugging support • Currently on MonoTouch 1.4.5
  30. 30. Debugger • MonoTouch debugger leverages Mono’s new Soft-Debugger • Supports the Simulator • Supports the Device... • even over WiFi
  31. 31. Debugger Features • Breakpoints • Catchpoints • Inspection • Watches • Immediate / Expression Evaluator • Call Stack • Stepping
  32. 32. Caveats • Debug binaries on devices are very large • Cannot debug Main or FinishedLaunching on device • Consumes more memory runtime • Performance hit
  33. 33. Getting started • Get iPhone SDK from Apple • Get Mono from Novell • Get MonoTouch (evaluation version is free) • Get MonoDevelop • Register with Apple iPhone Developer Program and purchase MonoTouch for putting apps on device and AppStore.
  34. 34. One more thing...
  35. 35. iPad • But you want to develop for the iPad... • 24 Hours after the SDK was released... • MonoTouch support for iPad
  36. 36. Demo time...
  37. 37. Q +A twitter.com/chrisntr chrisntr@gmail.com

×