Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Xamarin.iOS with Xamarin Studio

Xamarin.iOS with Xamarin Studio

A tour of iOS development in C# with Xamarin Studio. Demo code available on my GitHub repo (https://github.com/patridge/demos-xamarin.ios-tour).

patridge

May 21, 2013
Tweet

More Decks by patridge

Other Decks in Programming

Transcript

  1. Objective-C isn't that bad... // Putting multiple lines of text

    in a label. - (void)viewDidLoad { [super viewDidLoad]; CGRect labelFrame = CGRectMake(20, 20, 280, 150); UILabel *myLabel = [[UILabel alloc] initWithFrame:labelFrame]; [myLabel setBackgroundColor:[UIColor orangeColor]]; NSString *labelText = @"Here is a long block of text that will probably wrap when put on a small screen."; [myLabel setText:labelText]; // Tell the label to use an unlimited number of lines [myLabel setNumberOfLines:0]; [myLabel sizeToFit]; [self.view addSubview:myLabel]; } From most popular iOS Stackoverflow question: http://bit.ly/topiosquestion
  2. ...but if you already know C# // Putting multiple lines

    of text in a label. public override void ViewDidLoad() { base.ViewDidLoad(); RectangleF labelFrame = new RectangleF(20, 20, 280, 150); UILabel myLabel = new UILabel(labelFrame); myLabel.BackgroundColor = UIColor.Orange; myLabel.Text = "Here is a long block of text that will probably wrap when put on a small screen."; myLabel.Lines = 0; myLabel.SizeToFit(); View.AddSubview(myLabel); }
  3. And you get some fun syntactic sugar... // Putting multiple

    lines of text in a label. public override void ViewDidLoad() { // :P base.ViewDidLoad(); UILabel myLabel = new UILabel(new RectangleF(20, 20, 0, 0)) { BackgroundColor = UIColor.Orange, Text = "Here is a long block of text that will probably wrap when put on a small screen.", Lines = 0, }; myLabel.SizeToFit(); Add(myLabel); }
  4. Who is Xamarin? • 2001: Ximian brings .NET to Linux

    with Mono • 2003: Novell buys Ximian • 2009: MonoTouch released • 2011: ◦ April: MonoDroid [Mono for Android] released ◦ April: Attachmate buys Novell ◦ May: Attachmate lays off Novell ◦ May: Xamarin is born; announces future mobile products ◦ July: Xamarin given perpetual license to use MonoTouch and Mono for Android Worried about Apple + Xamarin? http://bit.ly/applelessevil
  5. What do I get? • Code ◦ C# goodness from

    most of System.Whatever* ◦ Native APIs in C#-flavored syntax (same-day for new) ◦ Garbage Collection • Tools ◦ Xamarin Studio ◦ Xamarin Component Store *Some restrictions apply: http://bit.ly/xamarinioslimits
  6. How much? Starter $0 small apps Indie $299 any app

    Business $999 Visual Studio integration, email support Enterprise $1899 premium support and premium components
  7. Links • Xamarin http://xamarin.com/ • Getting Started http://docs.xamarin.com/ • Advanced

    Concepts on iOS (and others) ◦ Cross-platform MVVM https://github. com/slodge/MvvmCross ◦ IoC https://github.com/grumpydev/TinyIoC ◦ Unit Tests http://www.nunitlite.com/ @patridgedev patridgedev.com