<?xml version="1.0" encoding="utf-8"?>
<!--Generated by RSS.NET: http://rss-net.sf.net-->
<rss version="2.0">
  <channel>
    <title>Miguel's OSX and iOS blog</title>
    <description>Miguel's OSX and iOS blog</description>
    <link>http://tirania.org/monomac//index.html</link>
    <copyright>Miguel de Icaza</copyright>
    <managingEditor>miguel@xamarin.com</managingEditor>
    <pubDate>Mon, 11 Nov 2013 17:09:00 -0500</pubDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>lb#</generator>
    <item>
      <title>Inside the Sausage Factory: Xamarin iOS/Mac 64 bit support</title>
      <description>
	&lt;p&gt;This blog post discusses Xamarin's current plans to support
	the 32 and 64 bit frameworks in our products.
	
	&lt;p&gt;When we first created the C# bridge to iOS
	with &lt;a href="http://xamarin.com/ios"&gt;MonoTouch&lt;/a&gt;, we mapped
	the data types from Objective-C to their equivalent data types
	in C#.  Since C# does not have an equivalent to "typedef" we
	also mapped type definitions into their underlying data types.

	&lt;p&gt;This means that we mapped C types like &lt;code&gt;int&lt;/code&gt;
	to &lt;code&gt;System.Int32&lt;/code&gt; (short: &lt;code&gt;int&lt;/code&gt;)
	&lt;code&gt;float&lt;/code&gt; to &lt;code&gt;System.Single&lt;/code&gt;
	(short: &lt;code&gt;float&lt;/code&gt;).  This is because on .NET
	the &lt;code&gt;int&lt;/code&gt; data type is defined to be a 32 bit
	integer, and long is always a 64 bit integer.

	&lt;p&gt;We also chose to map things like &lt;code&gt;CGRect&lt;/code&gt; to &lt;code&gt;RectangleF&lt;/code&gt;
	at this point.  But most importantly, we mapped things like
	&lt;code&gt;NSInteger&lt;/code&gt; as &lt;code&gt;int&lt;/code&gt;
	and &lt;code&gt;CGFloat&lt;/code&gt; to &lt;code&gt;float&lt;/code&gt;,
	since &lt;code&gt;NSInteger&lt;/code&gt; was a 32 bit value
	and &lt;code&gt;CGFloat&lt;/code&gt; was a 32 bit value.  We later did the
	same work for the &lt;a href="http://xamarin.com/Mac"&gt;Mac&lt;/a&gt; and
	we continued doing these mappings.

	&lt;p&gt;We were living in a 32-bit world.

	&lt;p&gt;The 64 bit version of OSX had
	defined &lt;code&gt;NSInteger&lt;/code&gt; and &lt;code&gt;CGFloat&lt;/code&gt; to be
	64 bit values, changing the assumptions that we had made.
	
	&lt;p&gt;The challenge to support 64 bits was that we would need to
	change the public API on our Mac APIs, stuff like:

&lt;pre class="code-csharp"&gt;
class Xxx {
	[Export ("getRowCount")]
	public int GetRowCount () {...}
}
&lt;/pre&gt;

	&lt;p&gt;Would become:

&lt;pre class="code-csharp"&gt;
class Xxx {
	[Export ("getRowCount")]
	public long GetRowCount () {...}
}
&lt;/pre&gt;

	&lt;p&gt;The above is problematic for two reasons.  We
	would need to audit all of our APIs to do the proper type
	mapping and we would break source code compatibility, with
	code like this:

&lt;pre class="code-csharp"&gt;
var foo = new Xxx ();
int count = foo.GetRowCount ();

// oops, can not cast a long into an int.
&lt;/pre&gt;

	&lt;p&gt;When we combined source code breakage with the fact that
	Apple had a 32-bit compatibility story and we had some legacy
	libraries that depended on 32-bit only APIs meant that we were
	in no rush to move to a 64-bit world.


&lt;h2&gt;OSX 64 bit frameworks&lt;/h2&gt;

	&lt;p&gt;With Mountain Lion, Apple started to ship a handful of
	their new frameworks only as 64-bit frameworks.   This means
	that for the first time, MonoMac was not able to provide
	bindings to some frameworks.

	&lt;p&gt;At this point, we realized that we had to get out of our
	32-bit comfort zone.   But we still needed to support 32-bits,
	since iOS was a 32-bit only API and OSX was turning into a
	64-bit only API.

	&lt;p&gt;We needed some way of sharing code.

	&lt;p&gt;At this point we had a number of options in our plate, to
	make a very long story short, we decided to do two things:

	&lt;ul&gt;
		&lt;li&gt;Audit all of our APIs and annotate every use of
		&lt;code&gt;NSInteger&lt;/code&gt; and provide tooling to ensure
		that we had both 32 and 64 bit APIs.  This would allow
		us to produce both 32 and 64 bit bindings.

		&lt;li&gt;Build a tool to help Mac users migrate their
		applications and upgrade their uses of the narrower
		data types to the wider ones.
	&lt;/ul&gt;

	&lt;p&gt;Our thinking was simple: every new Mac would be 64-bit
	capable.  So this means that we could support the old 32 bit
	API for existing Mac users, but new APIs would require the
	source code to be upgraded to 64-bits, never to look back
	again.

	&lt;p&gt;There was little incentive to expand support for 32-bit
	only APis on the Mac.   The world was going 64.
	
	&lt;p&gt;We were executing on this process when Apple introduced the
	iPhone5s with a 64 bit processor.

&lt;h2&gt;iOS goes 64 bit&lt;/h2&gt;

	&lt;p&gt;The iPhone5s forced us to revisit our assumptions.

	&lt;p&gt;Apple introduced the 64-bit iPhone5s, but also introduced
	the iPhone5c which is a 32-bit processor.

	&lt;p&gt;This means that developers need to be able to target 32
	bits for at least some five years.

	&lt;p&gt;We had two choices with the old strategy with regards to
	iOS: either stay in the 32 bit world for the next five years
	or force users to maintain two codebases (one for 32 and one
	for 64).   Neither option was attractive.

	&lt;p&gt;So we resorted to a more sophisticated approach that we had
	originally dismissed.

&lt;h2&gt;Transparently Supporting 32 and 64 bit Code&lt;/h2&gt;

	&lt;p&gt;Our goals shifted.   While we could ask Mac users to do a
	one-time switch, we could not ask that from our iOS users.

	&lt;p&gt;We needed to support both 32 and 64 bit code from a single
	codebase, even if this required some magic beyond bindings.
	Compiler, linker and tooling would have to come together.

	&lt;p&gt;We are now going to keep our existing 32 bit APIs --for the
	sake of backwards compatibility for all of our iOS and Mac
	users-- and also introduce new APIs that are 32/64 bit ready.

	&lt;p&gt;We are doing this by introducing a few new data types:
	&lt;code&gt;nint&lt;/code&gt;, &lt;code&gt;nuint&lt;/code&gt; and &lt;code&gt;nfloat&lt;/code&gt;
	which are 32-bit wide on 32 bit architectures, and 64-bit wide
	on 64-bit architectures.

	&lt;p&gt;We would also move
	from &lt;code&gt;RectangleF&lt;/code&gt;, &lt;code&gt;SizeF&lt;/code&gt;
	and &lt;code&gt;PointF&lt;/code&gt;
	to &lt;code&gt;CGRect&lt;/code&gt;, &lt;code&gt;CGSize&lt;/code&gt;
	and &lt;code&gt;CGPoint&lt;/code&gt; which would be defined not in terms
	of the C# float data type, but in terms
	of &lt;code&gt;nfloat&lt;/code&gt;.

	&lt;p&gt;These data types will live in the &lt;code&gt;System&lt;/code&gt;
	namespace inside the &lt;code&gt;Xamarin.iOS.dll&lt;/code&gt;
	and &lt;code&gt;Xamarin.Mac.dll&lt;/code&gt;.

	&lt;p&gt;These are defined roughly like this:

&lt;pre class="code-csharp"&gt;
struct nint {
#if 64
	long value;
#else
	int value;
#endif
}
&lt;/pre&gt;

	&lt;p&gt;By defining these are plain structs, we ensure that any
	code using these data types is legal C#, compatible with
	Microsoft's C#.

	&lt;p&gt;But at runtime, depending on which platform you are
	running, you will get either 32 or 64 values.

	&lt;p&gt;This means that all of the Objective-C APIs
	using &lt;code&gt;NSInteger&lt;/code&gt; that we originally had mapped
	to &lt;code&gt;int&lt;/code&gt; will now take an &lt;code&gt;nint&lt;/code&gt; but
	also that users can choose to stay on a 32-bit world, or have
	code that automatically compiles to both 32 and 64 bit at the
	same time.

	&lt;p&gt;This means that the original GetRowCount example would now
	be written like this:

&lt;pre class="code-csharp"&gt;
class Xxx {
	[Export ("getRowCount")]
	public nint GetRowCount () {...}
}

// ...

var foo = new Xxx ();
nint count = foo.GetRowCount ();
&lt;/pre&gt;

	&lt;p&gt;In the above case, &lt;code&gt;count&lt;/code&gt; will be a 32 bit
	value on 32 bit systems and 64 on 64 bit systems.
	
	&lt;p&gt;We added implicit and explicit operator conversions from
	and to the underlying data types.  We follow
	the &lt;a href="http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321545613"&gt;.NET
	Framework Design Guidelines&lt;/a&gt; for implicit and explicit
	operators, with an added twist: we only consider implicit
	conversions when there would be no data loss in the
	32 &lt;b&gt;and&lt;/b&gt; the 64 bit worlds.  Otherwise you must use
	explicit conversions, like this:

&lt;pre class="code-csharp"&gt;
public struct nint {
    // Implicit conversions
    static implicit operator nint  (Int32 v);
    static implicit operator Int64 (nint v);

    // Explicit conversions
    static explicit operator Int32  (nint v);
    static explicit operator nint   (Int64 v);
    static explicit operator UInt32 (nint v);
    static explicit operator UInt64 (nint v);

    // Explicit IntPtr conversions
    static explicit operator IntPtr (nint v);
    static explicit operator nint   (IntPtr v);
    static explicit operator nint   (IntPtr v);
}
&lt;/pre&gt;

	&lt;p&gt;This means that you can always go from an &lt;code&gt;nint&lt;/code&gt;
	to a C# &lt;code&gt;long&lt;/code&gt;.   But going from
	a &lt;code&gt;nint&lt;/code&gt; to an &lt;code&gt;int&lt;/code&gt; requires a cast as
	there would be data loss in the case where the nint is a 64
	bit value.
	
	&lt;p&gt;For example:

&lt;pre class="code-csharp"&gt;
// valid, implicit conversion:
long count = foo.GetRowCount ();

// error:
int count = foo.GetRowCount ();

// use an explicit cast, valid:
int count = (int) foo.GetRowCount ();
&lt;/pre&gt;

	&lt;p&gt;Astute readers, or those familiar with .NET, will notice that:

&lt;pre class="code-csharp"&gt;
int Add (int a, int b)
{
	return a+b;
}

int Add (nint a, nint b)
{
	return a+b;
}
&lt;/pre&gt;

	&lt;p&gt;Will compile down to drastically different IL.

	&lt;p&gt;The first uses native ECMA IL instructions to perform the
	addition, while the second compiles to a &lt;code&gt;call op_Addition&lt;/code&gt;

	&lt;p&gt;We have taught our VM to understand these new data types
	and treat them in the same way that we would treat a native
	type.  This means that there is no performance difference
	between the use of &lt;code&gt;int&lt;/code&gt; vs &lt;code&gt;nint&lt;/code&gt;.
	The &lt;code&gt;call op_Addition&lt;/code&gt; ends up being the same as
	the native ECMA CIL add instructions.  The IL might look
	scarier, but the native code is identical.

	&lt;p&gt;We chose the names &lt;code&gt;nint&lt;/code&gt;, &lt;code&gt;nuint&lt;/code&gt;
	over the built-in &lt;code&gt;IntPtr&lt;/code&gt;
	and &lt;code&gt;UIntPtr&lt;/code&gt;, because they felt natural "native
	integers" as opposed to the cultural association
	that &lt;code&gt;IntPtr&lt;/code&gt; has with pointer or a native token.
	Additionally, we did not have the equivalent native floating
	point type.

	&lt;p&gt;We chose to stay away from using the
	names &lt;code&gt;NSInteger&lt;/code&gt; and &lt;code&gt;CGFloat&lt;/code&gt; for a
	couple of reasons: the functionality is general enough that it
	might be worth using in Mono in places beyond Mac and iOS and
	because it feels like these are real VM supported types as
	opposed to some type definition or alias.  In an ideal world,
	these would eventually be part of the C# standard.

&lt;h2&gt;What will the world look like?&lt;/h2&gt;

	&lt;p&gt;Users that are happy living in the pure 32 bit world will
	get to keep using their existing assemblies and project types
	(&lt;code&gt;monotouch.dll&lt;/code&gt; and &lt;code&gt;MonoMac.dll&lt;/code&gt;/&lt;code&gt;XamMac.dll&lt;/code&gt;).

	&lt;p&gt;Users that want to adopt new 64-bit only APIs, or want to
	have their code automatically run on 32 or 64 depending on the
	target CPU will use the new &lt;code&gt;Xamarin.iOS.dll&lt;/code&gt; and
	&lt;code&gt;Xamarin.Mac.dll&lt;/code&gt; assemblies and a new project type that knows
	how to build dual 32/64 binaries transparently.

	&lt;p&gt;One added benefit of this new design is that third party
	components and libraries will automatically be 32/64 bit
	ready. 

	&lt;p&gt;We will also distribute the same tools that we used to
	upgrade from 32 to 32/64 to assist our users that want to
	migrate existing codebases to the new 32/64 bit world.
	
	
</description>
      <link>http://tirania.org/monomac/archive/2013/Nov-11.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Nov-11.html</guid>
      <pubDate>Mon, 11 Nov 2013 22:09:00 -0500</pubDate>
    </item>
    <item>
      <title>Awaitable ShowAlert</title>
      <description>
	&lt;p&gt;&lt;a href="https://twitter.com/chknofthescene"&gt;Alex
	Corrado&lt;/a&gt; shared with me a trick to easily show UIAlertViews
	without ceremony.

	&lt;p&gt;You use it like this:

	&lt;pre&gt;
async void Demo ()
{
    switch (await ShowAlert ("Title", "Message", "Ok", "Cancel")){
	case 0: // Ok
	    ....
        case 1: // Cancel
            ....
    }
}
	&lt;/pre&gt;

	&lt;p&gt;The beauty is being able to show alerts and linearly
	decide what to do with the result.

	&lt;p&gt;Here is the helper method:

&lt;pre&gt;
// Displays a UIAlertView and returns the index of the button pressed.
public static Task&lt;int&gt; ShowAlert (string title,
                                   string message,
                                   params string [] buttons)
{
    var tcs = new TaskCompletionSource&lt;int&gt; ();
    var alert = new UIAlertView {
        Title = title,
        Message = message
    };
    foreach (var button in buttons)
        alert.AddButton (button);
    alert.Clicked += (s, e) =&gt; tcs.TrySetResult (e.ButtonIndex);
    alert.Show ();
    return tcs.Task;
}
&lt;/pre&gt;
</description>
      <link>http://tirania.org/monomac/archive/2013/Oct-03.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Oct-03.html</guid>
      <pubDate>Thu, 03 Oct 2013 14:50:00 -0500</pubDate>
    </item>
    <item>
      <title>Using RevealApp with MonoTouch</title>
      <description>
	&lt;p&gt;To use &lt;a href="http://revealapp.com/"&gt;RevealApp&lt;/a&gt; with
	Xamarin.iOS, this is all you have to do:

	&lt;ul&gt;
		&lt;li&gt;Download the Reveal Beta

		&lt;li&gt;Use the Finder to go to the location where Reveal
		was downloaded to, and use the Finder's "Show Package
		Contents".

		&lt;br/&gt;
		&lt;img src="http://tirania.org/pictures/reveal-app.png"&gt;
		&lt;br/&gt;
		
		&lt;li&gt;Open the contents and drag the file "Reveal" from
		the iOS-Libraries directory into your Xamarin Studio
		project.

		&lt;br/&gt;
		&lt;img src="http://tirania.org/s/cd162acd.png"&gt;
		&lt;br/&gt;
		&lt;li&gt;Change the properties in Xamarin Studio for the
		file and set "Build Action" to None:

		&lt;br/&gt;
		&lt;img src="http://tirania.org/s/cd162acd.png"&gt;
		&lt;br/&gt;
		
		&lt;li&gt;Tell Xamarin Studio to link the library:
		&lt;br/&gt;
		&lt;img src="http://tirania.org/s/a68cfc37.png"&gt;
		&lt;br/&gt;
	&lt;/ul&gt;

	&lt;p&gt;Run your app, and it should then show up on the Reveal UI
</description>
      <link>http://tirania.org/monomac/archive/2013/Sep-29.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Sep-29.html</guid>
      <pubDate>Sun, 29 Sep 2013 15:43:00 -0500</pubDate>
    </item>
    <item>
      <title>Adopting iOS7 Dynamic Type in Your App</title>
      <description>
	&lt;p&gt;Before iOS7, developers could either get the system font in
	regular, italic or bold and a small font, using APIs like
	this:

	&lt;pre&gt;
static UIFont SystemFontOfSize     (float size);
static UIFont BoldSystemFontOfSize (float size);
	&lt;/pre&gt;

	&lt;p&gt;Developers could use the &lt;tt&gt;SystemFontSize&lt;/tt&gt; to get the
	system font size, but beyond this single number there was no
	guidance as to what font sizes to use.  It was
	every-man-for-himself kind of place, not too different from
	the wild west, where people like me would pick 14 because we
	need glasses, and avant garde designers would pick 11 points.

	&lt;p&gt;It was madness!

&lt;h2&gt;Guidance&lt;/h2&gt;

	&lt;p&gt;To assist making applications more consistent, developers
	now have acces a series of pre-configured fonts that can be
	used in various scenarios, these are available first as
	properties directly on UIFont:

	&lt;pre&gt;
static UIFont UIFont.PreferredHeadline    { get; }
static UIFont UIFont.PreferredSubheadline { get; }
static UIFont UIFont.PreferredBody        { get; }
static UIFont UIFont.PreferredCaption1 { get; }
static UIFont UIFont.PreferredCaption2 { get; }
static UIFont UIFont.PreferredFootnote { get; }
&lt;/pre&gt;

	&lt;p&gt;Apple's documentation states that the fonts returned have
	their properties adjusted to be optimized for reading.   The
	most noticeable attribute those fonts have is the default font
	and their font sizes.
	
	&lt;p&gt;This is how they look like at the default size:

	
	&lt;center&gt;
	&lt;img src="http://tirania.org/s/a5d82df0.png" style="border-width:1px; border-color:rgb(215,215,228);	border-style: solid"&gt;
	&lt;/center&gt;

	&lt;p&gt;And this is how they look when the text size in the system
	is set to the largest size (my default):
	
	&lt;center&gt;
	&lt;img src="http://tirania.org/s/a7d0063e.png" style="border-width:1px; border-color:rgb(215,215,228);	border-style: solid"&gt;
	&lt;/center&gt;

	&lt;p&gt;Merely accessing the &lt;code&gt;UIFont&lt;/code&gt; properties will return the
	properly sized font depending on the user settings.

&lt;h2&gt;Responding to User's settings&lt;/h2&gt;

	&lt;p&gt;With iOS7, the user can change the desired size for his
	fonts in the Settings application.  Applications in turns
	should respond by adjusting their contents.  They do this by
	using the freshly minted fonts that the system has created for
	them in the &lt;code&gt;UIFont&lt;/code&gt; properties and respond to the system
	notification that the user has made a font size change.

	&lt;p&gt;To do this, you register a 
	&lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.UIKit.UIApplication%2bNotifications.ObserveContentSizeCategoryChanged"&gt;UIApplication.Notification&lt;/a&gt;,
	like this:

	&lt;pre&gt;&lt;code&gt;
UIApplication.Notifications.ObserveContentSizeCategoryChanged (delegate {
    // text size has changed, reconfigure any UIViews's font here

    // Simple:
    exampleLabel.font = UIFont.PreferredBody;
});
	&lt;/code&gt;&lt;/pre&gt;
	
&lt;h2&gt;Customizing the Fonts&lt;/h2&gt;

	&lt;p&gt;UIKit Developers now have access to all of the advanced
	typographic control available in CoreText.  The interface to
	customize fonts is provided by
	the &lt;a href="http://iosapi.xamarin.com/?link=T%3aMonoTouch.UIKit.UIFontDescriptor"&gt;&lt;code&gt;UIFontDescriptor&lt;/code&gt;&lt;/a&gt; class.  You can fetch a
	&lt;code&gt;UIFontDescriptor&lt;/code&gt; a &lt;code&gt;UIFont&lt;/code&gt; by accessing its FontDescriptor
	property, and you can in turn create UIFonts by configuring a
	&lt;code&gt;UIFontDescriptor&lt;/code&gt; and requesting that a font be
	created for you.

	&lt;p&gt;This is what you do to create a bold or italic fonts:

	&lt;pre&gt;&lt;code&gt;
UIFont MakeBold (UIFont font)
{
    var desc = font.FontDescriptor;

    // create a new descriptor based on the baseline, with
    // the requested Bold trait
    var bold = desc.CreateWithTraits (UIFontDescriptorSymbolicTraits.Bold);

    // Create font from the bold descriptor
    return UIFont.FromDescriptor (bold);
}
	&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;You use &lt;code&gt;UIFontDescriptorSymbolicTraits.Italic&lt;/code&gt;
	for creating an italic font, this is what text looks like for
	the PreferredBody by default:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/5e295d7a.png" style="border-width:1px; border-color:rgb(215,215,228);	border-style: solid"&gt;
	&lt;/center&gt;

	&lt;p&gt;Other simple traits that you can apply to a font include
	the interline spacing.   Something that was not possible
	previously:

&lt;div style="border-width:1px; border-color:rgb(215,215,228);	border-style: solid"&gt;
&lt;img align=top src="http://tirania.org/s/ab55ff85.png" style="width:210;vertical-align:top;" &gt;&amp;nbsp;
&lt;img align=top src="http://tirania.org/s/5da8dbc6.png" style="width:210;vertical-align:top;" &gt;&amp;nbsp;
&lt;img align=top src="http://tirania.org/s/945b433e.png" style="width:210;vertical-align:top;" &gt;&amp;nbsp;
&lt;br&gt;
&lt;/div&gt;

	&lt;p&gt;To achieve the above, all you have to do is pass the
	&lt;code&gt;UIFontDescriptorSymbolicTraits.TightLeading&lt;/code&gt; or
	&lt;code&gt;UIFontDescriptorSymbolicTraits.LooseLeading&lt;/code&gt;
	parameters to the &lt;code&gt;CreateWithTraits&lt;/code&gt; method.

&lt;h2&gt;Using CoreText Font Features&lt;/h2&gt;

	&lt;p&gt;While the above will be enough for many applications,
	CoreText provides comprehensive access to many features
	of underlying fonts.

	&lt;p&gt;You can use
	the &lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.UIKit.UIFontDescriptor.CreateWithAttributes(MonoTouch.UIKit.UIFontAttributes)"&gt;&lt;code&gt;UIFontDescriptor.CreateWithAttributes&lt;/code&gt;&lt;/a&gt;
	method to pass your detailed list
	of &lt;a href="http://iosapi.xamarin.com/index.aspx?link=T%3aMonoTouch.UIKit.UIFontAttributes"&gt;&lt;code&gt;UIFontAttributes&lt;/code&gt;&lt;/a&gt;
	that you want to set on your font.

	&lt;p&gt;The following example shows how to request the use of
	proportional numbers in the default font:
	
	&lt;pre&gt;&lt;code&gt;
public UIFont ResizeProportional (UIFont font)
{
    var attributes = new UIFontAttributes (
	new UIFontFeature (
	   CTFontFeatureNumberSpacing.Selector.ProportionalNumbers));
    var newDesc = font.FontDescriptor.CreateWithAttributes (attributes);
    return UIFont.FromDescriptor (newDesc, 40);	
}
	&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;The nice thing about these strong types is that
	code-completion in the editor basically provides you with a
	visual guide of which attributes are available for you to
	use.   This is the result of the above code when rendering
	numbers:
	
	&lt;center&gt;
	&lt;img src="http://tirania.org/s/89733b98.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;The above is just a sample, you can use any of
	the &lt;a href="http://iosapi.xamarin.com/?link=N:MonoTouch.CoreText"&gt;CoreText
	Font Features&lt;/a&gt; to customize the rendering of your font.

	&lt;p&gt;Some other variations:
	&lt;center&gt;
	&lt;img src="http://tirania.org/s/2622f997.png"&gt;
	&lt;/center&gt;
	
	&lt;p&gt;The entire sample showing these features is available in
	the 
	&lt;a href="https://github.com/xamarin/monotouch-samples/tree/master/ios7fonts"&gt;ios7fonts&lt;/a&gt; directory.

	
</description>
      <link>http://tirania.org/monomac/archive/2013/Sep-25.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Sep-25.html</guid>
      <pubDate>Wed, 25 Sep 2013 21:45:00 -0500</pubDate>
    </item>
    <item>
      <title>CFNetwork-powered HttpClient</title>
      <description>
	&lt;p&gt;Newer versions of .NET introduced a new Http client API:
	&lt;a href="http://msdn.microsoft.com/en-us/library/system.net.http.httpclient.aspx"&gt;HttpClient&lt;/a&gt;.
	This new API is designed to integrate naturally
	with &lt;a href="http://msdn.microsoft.com/en-us/library/vstudio/hh191443.aspx"&gt;C#
	async language extension&lt;/a&gt;.    Some of its virtues are
	described
	in &lt;a href="http://blogs.msdn.com/b/henrikn/archive/2012/02/11/httpclient-is-here.aspx"&gt;Henrik's
	blog post&lt;/a&gt;.

	&lt;p&gt;While HttpClient by default uses the .NET framework's
	HttpWebRequest for actually connecting to the server, the API
	was designed to allow other implementations of the HTTP stack
	to be used instead.

	&lt;p&gt;With both the beta versions of MonoTouch and the upcoming
	Xamarin.Mac, you can now use CFNetwork as your HTTP
	transport.   To do this, all you have to do is change your
	instantiation from:

	&lt;pre class="code-csharp"&gt;
var client = new HttpClient ();
&lt;/pre&gt;

	&lt;p&gt;To:

	&lt;pre class="code-csharp"&gt;
var client = new HttpClient (CFNetworkHandler ());
&lt;/pre&gt;

	&lt;p&gt;Using CFNetwork for your http client has the following
	differences from HttpWebRequest:

	&lt;ul&gt;

		&lt;li&gt;On iOS, CFNetwork will automatically turn on the
		phone's radio if it is off before starting the HTTP
		request.   This means that you no longer need to
		manually use
		the &lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.ObjCRuntime.Runtime.StartWWAN(System.Uri%2cSystem.Action%3CSystem.Exception%3E)"&gt;StartWWAN&lt;/a&gt;
		&lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.ObjCRuntime.Runtime.StartWWAN(System.Uri)"&gt;methods&lt;/a&gt;.

		&lt;li&gt;Connection pooling is managed
		by &lt;a href="https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFHTTPStreamRef/Reference/reference.html"&gt;CFNetwork&lt;/a&gt;
		as opposed to the settings in .NET's stack.

		&lt;li&gt;Will automatically track proxy and network
		settings done to iOS.

		&lt;li&gt;Operations are performed on the CFNetwork
		dispatch queues/threads instead of consuming threads
		from Mono's own managed thread pool.
	&lt;/ul&gt;

	&lt;p&gt;In both cases, you will be able to continue using the same
	APIs, the only difference is in how you construct your
	HttpClient. 
</description>
      <link>http://tirania.org/monomac/archive/2013/Jun-07.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Jun-07.html</guid>
      <pubDate>Fri, 07 Jun 2013 19:52:00 -0500</pubDate>
    </item>
    <item>
      <title>Contribute Your Storyboard Files for Humanity</title>
      <description>
	&lt;p&gt;Ok, ok, not quite for humanity.

	&lt;p&gt;We are trying to improve our support for Xamarin Studio
	integration with Storyboard files, and we would like to
	collect a bunch of different samples.

	&lt;p&gt;If you can share your &lt;code&gt;.storyboard&lt;/code&gt; file with
	us, please email alan at xamarin.com just the .storyboard file

</description>
      <link>http://tirania.org/monomac/archive/2013/Mar-11.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Mar-11.html</guid>
      <pubDate>Mon, 11 Mar 2013 15:33:00 -0500</pubDate>
    </item>
    <item>
      <title>Using Instruments to profile Mac apps built with Mono</title>
      <description>
	&lt;p&gt;On most platforms, Mono generates code dynamically as your
	software runs.  The Instruments profiler does not have the
	ability to map a memory address of the generated code back to
	the name of your function being executed.   This makes it
	pretty hard to find the hot spots in your code, or the bit of
	code responsible for a memory leak.

	&lt;p&gt;To solve this problem, you can use Mono's ahead of time
	compiler to precompile your code to native code.   This will
	improve startup performance and also give you symbols in stack
	traces in Instruments.

	&lt;p&gt;To do this, run mono with the --aot flag over all of the
	assemblies that your project uses.   This is the script that I
	ran to precompile all of my system libraries:

&lt;pre&gt;
cd /mono/lib/mono
for i in `find gac -name '*dll'` */mscorlib.dll; do
   mono --aot $i
done
&lt;/pre&gt;

	&lt;p&gt;This precompiles all of the assemblies from the Global
	Assembly Cache (GAC) and also takes care of all of my
	mscorlib libraries (these are not loaded from the GAC).

	 &lt;p&gt;Then you need to add your own software:

&lt;pre&gt;
	 $ mono --aot bin/Debug/*.{exe,dll}
&lt;/pre&gt;

	&lt;p&gt;Now, when you use Instruments, you will get nice symbolic
	stack traces for your process. 

	&lt;p&gt;Thanks to Alan McGovern for showing me this trick.
</description>
      <link>http://tirania.org/monomac/archive/2013/Jan-03.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2013/Jan-03.html</guid>
      <pubDate>Thu, 03 Jan 2013 18:50:00 -0500</pubDate>
    </item>
    <item>
      <title>Translating Objective-C adopts-protocol idioms to C#</title>
      <description>
	&lt;p&gt;Sometimes when looking at Objective-C samples, you might
	run into code that adopts protocols and you wonder how to port
	that code to C#.   It typically looks like this:

&lt;pre&gt;
@interface TransparentOverlay : UIView &amp;lt;UITableViewDelegate, UITableViewDataSource&amp;gt;
{
}
&lt;/pre&gt;

	&lt;p&gt;The above means that the "TransparentOverlay" object
	subclasses UIView and adopts two protocols:
	UITableViewDataSource and UITableViewDelegate.

	&lt;p&gt;The above does not really work with MonoMac or MonoTouch,
	since we mapped protocols into classes.  In both bindings
	UITableViewDelegate and UITableViewDataSource
	are &lt;a href="http://docs.xamarin.com/ios/Guides/Advanced_Topics/API_Design#Models"&gt;"model"
	classes&lt;/a&gt;. 

	&lt;p&gt;The real meat of this is that somewhere in the
	implementation of TransparentOverlay, a UITableView will be
	created, and both its delegate and its data source will be
	configured to point to the TransparentOverlay source,
	something like this:

&lt;pre&gt;
- (void) setup
{
	myTableView = [[UITableView alloc] initWithFrame:...];
	myTableView.delegate = self;
	myTableView.dataSource = self;
}
&lt;/pre&gt;

	&lt;p&gt;The adopted protocol allows you to perform the assignemnt
	there.

	&lt;p&gt;The equivalent code in C# needs to create a helper class
	that derives from the model.  This is the full implementation:

&lt;pre&gt;
class TransparentOverlay : UIView {
    UITableView tableview;

    class MySources : UITableViewSource {
        TrasparentOverlay container;

        public MySources (TrasparentOverlay container)
        {
            this.container = container;
        }

	override void MethodOne ()
	{
            container.DoSomething ();
	}
    }

    void Setup ()
    {
        tableview = new UITableView (....);

        var mySource = new MySources (this);
        tableView.Delegate = mySource;
        tableView.DataSource = mySource;
    }
}&lt;/pre&gt;

	&lt;p&gt;Note that the UITableViewSource is an aggregated version of
	UITableViewDataSource and UITableViewDelegate, it is just a
	convenience Model for a very common idiom.

	&lt;p&gt;As you can see, instead of using "self" to point to the
	"TransparentOverlay" instance, you need to make it point to
	the mySource instance.

	&lt;p&gt;The methods in MySource can get access to the content of
	their container by using the "container" property as
	illustrated by the MethodOne method.

</description>
      <link>http://tirania.org/monomac/archive/2012/Nov-27.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Nov-27.html</guid>
      <pubDate>Tue, 27 Nov 2012 16:00:00 -0500</pubDate>
    </item>
    <item>
      <title>CoreMIDI in MonoTouch/MonoMac</title>
      <description>
	&lt;p&gt;&lt;img src="http://tirania.org/images/mt-coremidi.png" width=240
	align="right"&gt;This new release of MonoTouch (and MonoMac) come
	with our new CoreMidi bindings.  In the same spirit of the
	work that we did for AudioToolbox and other frameworks, we
	created a C# bindings that follows the .NET framework
	guidelines for the API.

	&lt;p&gt;When I started these bindings, I knew close to nothing
	about MIDI.   It is a framework that is not
	exactly &lt;a href="http://goodliffe.blogspot.com/2010/10/using-coremidi-in-ios-example.html"&gt;well
	documented&lt;/a&gt; for people new to MIDI, but posts
	like &lt;a href="http://goodliffe.blogspot.com/2010/10/using-coremidi-in-ios-example.html"&gt;this&lt;/a&gt;
	helped me get these bindings sorted out.

	&lt;p&gt;MonoTouch/MonoMac binding resembles in many ways the
	object-oriented bindings that developers have created to make
	CoreMIDI &lt;a href="https://github.com/petegoodliffe/PGMidi"&gt;easier
	to digest&lt;/a&gt;.  At its core, it is still an object oriented
	framework, that happens to be exposed with a fairly hostile C
	interface.

	&lt;p&gt;Our interface surfaces the underlying object oriented
	system with a strongly typed C# interface.  Unlike the C
	interface that exposes a general property querying system that
	applies to all midi objects (MidiDevice, MidiEndpoint,
	MidiEntity, MidiPort), the binding ensures that only the
	available properties for each main class are exposed.  This is
	a convenient way of avoiding a trip to the docs and to google
	to find samples.

	&lt;center&gt;
	&lt;a href="http://iosapi.xamarin.com/?link=N%3aMonoTouch.CoreMidi"&gt;
	&lt;img src="http://iosapi.xamarin.com/monodoc.ashx?link=source-id:1:midi-components.png"
	width="400"&gt;
	&lt;/a&gt;
	&lt;/center&gt;

	&lt;p&gt;To save developers some pain, as I developed the binding, I
	documented my findings
	in
	the &lt;a href="http://iosapi.xamarin.com/?link=N%3aMonoTouch.CoreMidi"&gt;MonoTouch.CoreMIDI&lt;/a&gt;
	documentation and added various samples to our API docs:

	&lt;p&gt;Our &lt;a href="https://github.com/xamarin/monotouch-samples/tree/master/CoreMidiSample"&gt;CoreMidiSample&lt;/a&gt;
	is a tiny program that replicates most of the funcionality of
	the MIDI sample apps, and is an easy starting point for people
	that want to get started with MIDI on iOS.

	&lt;p&gt;Interesting CoreMidi events are turned into C# events, so
	you can listen to changes like this:

	&lt;pre class="code-csharp"&gt;
client = new MidiClient ("CoreMidiSample MIDI CLient");
client.ObjectAdded += delegate(object sender, ObjectAddedOrRemovedEventArgs e) {
	Console.WriteLine ("Object {0} added to {1}", e.Child, e.Parent);
};
client.ObjectRemoved += delegate(object sender, ObjectAddedOrRemovedEventArgs e) {
	Console.WriteLine ("Object {0} removed to {1}", e.Child, e.Parent);
};
client.PropertyChanged += delegate(object sender, ObjectPropertyChangedEventArgs e) {
	Console.WriteLine ("Property {0} changed on {1}", e.PropertyName, e.MidiObject);
};
client.ThruConnectionsChanged += delegate {
	Console.WriteLine ("Thru connections changed");
};
client.SerialPortOwnerChanged += delegate {
	Console.WriteLine ("Serial port changed");
};

//
// Create your input and output ports
//
outputPort = client.CreateOutputPort ("CoreMidiSample Output Port");
inputPort = client.CreateInputPort ("CoreMidiSample Input Port");

// Print out packets when we receive them
inputPort.MessageReceived += delegate(object sender, MidiPacketsEventArgs e) {
    Console.WriteLine ("Got {0} packets", e.Packets.Length);
};	
	&lt;/pre&gt;
</description>
      <link>http://tirania.org/monomac/archive/2012/Sep-11.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Sep-11.html</guid>
      <pubDate>Tue, 11 Sep 2012 22:07:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoTouch and UIKit Thread Safety</title>
      <description>
	&lt;p&gt;No major UI toolkit is thread safe.

	&lt;p&gt;This means that these toolkits are not designed to have
	their exposed methods be invoked by multiple threads at the
	same time from multiple threads.  The main reason is that
	building thread safe toolkits is both a very hard problem and
	can have very complicated semantics for the consumer of the
	toolkit.

	&lt;p&gt;Developers typically use multiple threads in UI
	applications to offload tasks that would otherwise block the
	user interface.   The work is offloaded to a background thread
	that can take as long as it wants or can perform various
	blocking operations like disk or network operations without
	affecting the interactive nature of the application.

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/98851931.png"&gt;
	&lt;/center&gt;
	
	&lt;p&gt;When the background code completes its work, it queues an
	operation to be executed on the main thread to perform any
	required UI updates.

	&lt;p&gt;In MonoTouch and MonoMac the queuing of the operation from
	the background thread to the main thread is done using the
	&lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.Foundation.NSObject.InvokeOnMainThread(MonoTouch.Foundation.NSAction)"&gt;InvokeOnMainThread&lt;/a&gt;
	or &lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.Foundation.NSObject.BeginInvokeOnMainThread(MonoTouch.Foundation.NSAction)"&gt;BeginInvokeOnMainThread&lt;/a&gt;
	methods.

	&lt;p&gt;The rule among toolkits is: do not access any toolkit APIs
	from the background thread since there is nothing in the
	toolkit API to defend against internal state corruption caused
	by multiple threads updating internals at the same time.
	Failure to follow this rule can lead to subtle bugs or
	crashes.  The offending code is typically very hard to track
	down since the problem is timing sensitive and the corruption
	can vary from run to run.

&lt;h2&gt;Helping Developers Write Better Code&lt;/h2&gt;

	&lt;p&gt;In theory, it is very easy to avoid making UIKit calls from
	a background thread, it only takes discipline.  But some
	developers are not even aware that they are making UIKit calls
	from a background thread because their code so far has not
	crashed (they have been mostly luck).  Another problem is that
	software is continuously evolving, and it is possible for
	developers to accidentally use UIKit APIs from a background
	thread during a refactoring pass, or when new features are
	introduced by a team members that was not aware of the clean
	split. 
	
	&lt;p&gt;With MonoTouch 5.4 we have introduced a feature that will
	help you track incorrect uses of UIKit from a background
	thread.   

	&lt;p&gt;Starting with this release, debug builds of your
	application will throw
	a &lt;a href="http://iosapi.xamarin.com/?link=T%3aMonoTouch.UIKit.UIKitThreadAccessException"&gt;UIKitThreadAccessException&lt;/a&gt;
	exception if you try to invoke a UIKit method from a background
	thread.

	&lt;p&gt;This is what the exception will look like:

&lt;pre&gt;
MonoTouch.UIKit.UIKitThreadAccessException:
    UIKit Consistency error: you are calling a UIKit method that can only
    be invoked from the UI thread.

  at MonoTouch.UIKit.UIApplication.EnsureUIThread
  at MonoTouch.UIKit.UIView.get_Subviews
  at Sample.AppDelegate.&lt;FinishedLaunching&gt;m__0
&lt;/pre&gt;

	&lt;p&gt;This is a fabulous tool.   It founds bugs in my own code
	within a few seconds of me using my own software.   Sometimes
	the bug is right there for you to see, but do not notice the
	mistake.


&lt;h2&gt;The Whitelist&lt;/h2&gt;

	&lt;p&gt;Over time, Apple has made some of UIKit APIs thread safe.
	This means that there are certain APIs that can safely be used
	concurrently by both the main thread and background threads.
	Those are documented in MonoTouch's documentation

	&lt;p&gt;Our list is based on what Apple has publicly documented as
	thread safe in different forums.  It is likely that more types
	and methods will become thread safe in the future, and when
	that happens, MonoTouch will will remove the particular check
	for debug builds for it.

&lt;h2&gt;Controlling The Thread Safety Check&lt;/h2&gt;

	&lt;p&gt;By default MonoTouch is configured to perform the thread
	checks only on debug builds of your software.    If you want
	to have these checks performed also during release builds, you
	can pass the &lt;tt&gt;--force-thread-check&lt;/tt&gt; to the mtouch
	compiler.

	&lt;p&gt;You might want to disable this check for a couple of
	reasons.   You might have a big infringing codebase that is
	mostly working for you now, and can not afford to go fix these
	bugs right away.   Or you could get confirmation from Apple
	that it is safe to call an API from a background thread.
	With MonoTouch, we have opted to be conservative and go by
	what is documented, but it is very possible that there are
	some APIs that are thread safe and just have not been
	documented as such. 
	
	&lt;p&gt;You can disable the feature for debug builds by passing
	the &lt;tt&gt;--disable-thread-check&lt;/tt&gt; flag to the compiler, or
	you can do this at runtime by changing the value
	of &lt;a href="http://iosapi.xamarin.com/?link=F%3aMonoTouch.UIKit.UIApplication.CheckForIllegalCrossThreadCalls"&gt;UIApplication.CheckForIllegalCrossThreadCalls&lt;/a&gt;,
	like this:

&lt;pre class="code-csharp"&gt;
//
// Disable UIKit thread checks for a couple of methods
//
var previous = UIApplication.CheckForIllegalCrossThreadCalls;
UIApplication.CheckForIllegalCrossThreadCall = false;

// Perform some UIKit calls here
foo.Bar = 1;

// Restore
UIApplication.CheckForIllegalCrossThreadCalls = previous;
&lt;/pre&gt;

&lt;h2&gt;Adding Your Own Checks&lt;/h2&gt;

	&lt;p&gt;If are building a library that wants to enforce the same
	kind of checks, you should call the
	new &lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.UIKit.UIApplication.EnsureUIThread()"&gt;UIApplication.EnsureUIThread&lt;/a&gt;
	from your code to perform these checks.
</description>
      <link>http://tirania.org/monomac/archive/2012/Sep-10.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Sep-10.html</guid>
      <pubDate>Mon, 10 Sep 2012 17:03:00 -0500</pubDate>
    </item>
    <item>
      <title>Feedback Requested: Binding NSAttributedString</title>
      <description>
	&lt;p&gt;As NSAttributedString plays a big role, I have been trying
	to figure out a way of improving the process by which
	NSAttributedString are created from C#.

&lt;h2&gt;Status Today&lt;/h2&gt;

	&lt;p&gt;While we support the NSDictionary-based approach of
	creating the attributed needed for an attributed string, like
	this:

&lt;pre class="code-csharp"&gt;
var attrs = new NSMutableDictionary () {
  { NSAttributedString.FontAttributeName,
    UIFont.FromName ("Heletica 14") },

  { NSAttributedString.ForegroundColorAttributeName,
    UIColor.Black }
};

var myString = new NSAttributedString ("Hello", attrs);
&lt;/pre&gt;

	&lt;p&gt;If you ignore the fact that Helvetica 14 is an uninspiring
	and inconsequential font, the example above is error prone.

	&lt;p&gt;Developers can pass a UIColor where a UIFont was required,
	or a number or anything else.  They also have no idea what
	values are acceptable unless they take a trip to the
	documentation and find out which values are allowed, and the
	types of their values.


&lt;h2&gt;The Standard Choice&lt;/h2&gt;

	&lt;p&gt;What we have historicallly in situations like this is to
	create a helper, strongly typed class.  This allows the IDE to
	provide intellisense for this situation, explicitly listing
	the types allowed and ensuring that only the correct values
	are set.   If we use this approach, we would introduce a new
	class, let us say "NSStringAttributes":

&lt;pre class="code-csharp"&gt;
var attrs = new NSStringAttributes () {
  Font = UIFont.FromName ("Heletica 14"),
  ForegroundColor = UIColor.Black
};

var myString = new NSAttributedString ("Hello", attrs);
&lt;/pre&gt;

	&lt;p&gt;The only problem that I have with this approach is that now
	we have two classes: NSAttributedString which is the actual
	string with the given attribute and a class that has a name
	that resembles too much NSAttributedString.

	&lt;p&gt;My concern is not that seasoned developers would be
	confused between NSAttributedString and NSStringAttributes,
	but that developers new to the platform would rightfully ask
	why they need to know the differences about this.

	&lt;p&gt;The upside is that it follows the existing pattern in
	MonoTouch and MonoMac: use a strongly typed class, which
	internally produces the NSDictionary on demand.

&lt;h2&gt;Giving NSAttributedString special powers&lt;/h2&gt;

	&lt;p&gt;Another option is to give NSAttributedString special
	powers.  This would allow NSAttributedString instances to be
	configured like this:

&lt;pre class="code-csharp"&gt;
var myString = new NSAttributedString ("Hello") {
  Font = UIFont.FromName ("Helvetica 14"),
  ForegroundColor = UIColor.Black
}
&lt;/pre&gt;

	&lt;p&gt;To support the above configuration, we would have to delay
	the actual creation of the NSAttributedString from the
	constructor time until the object is actually used.

	&lt;p&gt;This would allow the user to set the Font, ForegroundColor
	and other properties up until the point of creation.   This
	would require the NSAttributedString type to be treated
	specially by the MonoTouch/MonoMac bindings.

	&lt;p&gt;It would also make the NSMutableAttributedString feel a bit
	better to use: users could make changes to the attributed
	string all day long, and apply changes to the various
	properties for the entire span of the text with a simple
	property value:

&lt;pre class="code-csharp"&gt;
var myString = new NSMutableAttributedString ("Hello");

// This:
myString.AddAttribute (
	NSAttributedString.ForegroundColorAttributeName,
	UIColor.Red,
	new NSRange (0, myString.Length));

// Would become:
myString.ForegroundColor = UIColor.Red;
&lt;/pre&gt;

	&lt;p&gt;There are a couple of downsides with the above approach.
	The actual attributes used for this string configuration would
	not be shared across different NSAttributedStrings, so for
	some code patterns, you would be better off not using this
	syntax and instead using the NSStringAttributes class. 

	&lt;p&gt;The other downside is that NSAttributedString properties
	could be set only up to the point of the string being used.
	Once the string is used, the values would be set in stone, and
	any attempt to change them would throw an exception, or issue
	a strongly worded message on the console.

	&lt;p&gt;And of course, the improved NSMutableAttributedString API
	improvements could be done independently of the property
	setters existing in the base class.

&lt;h2&gt;Others?&lt;/h2&gt;

	&lt;p&gt;Can anyone think of other strongly typed approaches to
	simplify the use of NSAttributedStrings that are not listed
	here? 

&lt;h2&gt;Update&lt;/h2&gt;

	&lt;p&gt;Thanks for your excellent feedback!   It helped us clarify
	what we wanted to do with the API.   We are going to go with
	the "Standard Choice", but with a small twist.

	&lt;p&gt;We came to realize that NSAttributedString is just a string
	with attributes, but the attributes are not set in stone.  It
	is really up to the consumer of the API to determine what the
	meaning of the attributes are.

	&lt;p&gt;We had a constructor that took a CTStringAttributes
	parameter which is used when you render text with CoreText.

	&lt;p&gt;What we are going to do is introduce a UIStringAttributes
	for iOS to set UIKit attributes and an NSStringAttributes for
	AppKit that will have the same behavior: they will be strongly
	typed classes that can be passed as a parameter to the
	NSAttributedString constructor.

	&lt;p&gt;So we will have basically three convenience and type safe
	constructors based on what you will be using the
	NSAttributedString with as well as the standard NSDictionary
	constructor for your own use:

&lt;pre class="code-csharp"&gt;
public class NSAttributedString : NSObject {
  public NSAttributedString (string str, NSDictionary attrs);
  public NSAttributedString (string str, CTStringAttributes attrs);

  // iOS only
  public NSAttributedString (string str, UIStringAttributes attrs);

  // OSX only
  public NSAttributedString (string str, NSStringAttributes attrs);
}
&lt;/pre&gt;

	&lt;p&gt;We will also provide convenience "GetAttributes" methods
	for all platforms:

&lt;pre class="code-csharp"&gt;
public class NSAttributedString : NSObject {
  public CTStringAttributes GetUIKitAttributes ();

  // Only on iOS
  public UIStringAttributes GetUIKitAttributes ();

  // Only on OSX
  public NSStringAttributes GetUIKitAttributes ();
}
&lt;/pre&gt;

	&lt;P&gt;Finally, we loved Mark Rendle's proposal of using default
	parameters and named parameters for C#.  This actually opened
	our eyes to a whole new set of convenience constructors that
	we can use to improve both the MonoTouch and MonoMac APIs.

	&lt;p&gt;This comes from a Sample I was working on:

&lt;pre class="code-csharp"&gt;
var text = new NSAttributedString (
    "Hello world",
    font: GetFont ("HoeflerText-Regular", 24.0f),
    foregroundColor: GetRandomColor (),
    backgroundColor: GetRandomColor (),
    ligatures: NSLigatureType.All, 
    kerning: 10, // Very classy!
    underlineStyle: NSUnderlineStyle.Single,
    shadow: new NSShadow () {
        ShadowColor = GetRandomColor (),
        ShadowOffset = new System.Drawing.SizeF (2, 2)
    },
    strokeWidth: 5);
#endif
&lt;/pre&gt;

	&lt;p&gt;The only open question is whether the parameter names in
	this case should be camelCase, or start with an uppercase
	letter (font vs Font and foregroundColor vs ForegroundColor).
	
	&lt;p&gt;The result on screen are beautiful!

</description>
      <link>http://tirania.org/monomac/archive/2012/Aug-24.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Aug-24.html</guid>
      <pubDate>Fri, 24 Aug 2012 17:47:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoMac Updates</title>
      <description>
	&lt;p&gt;Over the last couple of months we have been silently
	updating both the MonoMac APIs as well as the IDE support for
	it.  All of the features that
	I &lt;a href="http://tirania.org/monomac/archive/2012/Mar-06.html"&gt;talked
	back in March&lt;/a&gt; are now publicly available.

	&lt;p&gt;More code is now shared with the MonoTouch infrastructure,
	which means that every time that we improve our MonoTouch IDE
	support, MonoMac will be improved as well.

&lt;h2&gt;MonoDevelop Improvements for MonoMac&lt;/h2&gt;

	&lt;p&gt;The latest version of MonoDevelop that we released
	contains a significant update for developers.   In the past,
	you had to use a one-off dialog box to create packages,
	installers and prepare an app for AppStore distribution.

	&lt;p&gt;With the latest release, we have now turned these
	configuration options into settings that are part of the
	project.   This means that you can now configure these based
	on your selected project configuration, you can automate the
	builds, save your settings and most importantly, you have many
	more options at your disposal:

	&lt;center&gt;
	&lt;img src="http://tirania.org/pictures/monomac-packaging-2012.png"&gt;
	&lt;p&gt;MonoMac packaging settings.
	&lt;/center&gt;

	&lt;p&gt;Plenty of the settings that go into Info.plist are now
	available directly in the project settings as well as the
	support for maintaining your iCloud keys and sandbox
	requirements:

	&lt;center&gt;
	&lt;img src="http://tirania.org/pictures/monomac-settings-2012.png"&gt;
	&lt;p&gt;MacOS Project Settings.
	&lt;/center&gt;

	&lt;p&gt;We also brought the MonoTouch Info.plist editor into the
	IDE, this allows you to maintain your Info.plist directly from
	the IDE.   It is also a convenient place to declare which file
	types your application exports and consumes:

	&lt;center&gt;
	&lt;img src="http://tirania.org/pictures/monomac-infoplist-2012.png"&gt;
	&lt;p&gt;Info.plist Editor.
	&lt;/center&gt;

&lt;h2&gt;New Launcher&lt;/h2&gt;

	&lt;p&gt;In the past we used a shell script to start your program,
	the shell script would set a few environment variables and
	invoke Mono with your initial assembly.

	&lt;p&gt;We now ship a binary launcher that links with the Mono
	runtime and fixes several long standing issues involving
	application launching.

&lt;h2&gt;Getting the latest MonoMac&lt;/h2&gt;

	&lt;p&gt;To get the latest support for MonoMac, merely download
	MonoDevelop 3.0.4.1 (our latest build available
	from &lt;a href="http://www.monodevelop.com"&gt;monodevelop.com&lt;/a&gt;
	and you will get the entire package for Mac development.

&lt;h2&gt;Samples&lt;/h2&gt;

	&lt;p&gt;New samples in MonoMac show how
	to &lt;a href="https://github.com/mono/monomac/tree/master/samples/AnimatedClock"&gt;use
	CoreAnimation to animate custom C# properties&lt;/a&gt;.  Our own
	MacDoc sample which was supposed to be just a simple demo of
	WebKit, MonoMac and MonoDoc has turned into a full fledged
	documentation browser which is now part of our own products
	(MonoTouch).

	
</description>
      <link>http://tirania.org/monomac/archive/2012/Jul-27.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Jul-27.html</guid>
      <pubDate>Fri, 27 Jul 2012 13:49:00 -0500</pubDate>
    </item>
    <item>
      <title>Key-Value-Observing on MonoTouch and MonoMac</title>
      <description>
	&lt;p&gt;This morning Andres came by IRC asking questions about Key
	Value Observing, and I could not point him to a blog post that
	would discuss the details on how to use this on C#.

	&lt;p&gt; &lt;a href="https://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html"&gt;Apple's
	Key-Value Observing&lt;/a&gt; document contains the basics on how to
	observe changes in properties done to objects.
	
	&lt;p&gt;To implement Key-Value-Observing using MonoTouch or
	MonoMac all you have to do is pick the object that you want to
	observe properties on, and invoke the "AddObserver" method.

	&lt;p&gt;This method takes a couple of parameters: an object that
	will be notified of the changes, the key-path to the property
	that you want to observe, the observing options and a context
	object (optional).

	&lt;p&gt;For example, to observe changes to the "bounds" property on
	a UIView, you can use this code:

	&lt;pre class="code-csharp"&gt;
view.AddObserver (
	observer: this, 
	keyPath:  new NSString ("bounds"), 
	options:  NSKeyValueObservingOptions.New, 
	context:  IntPtr.Zero);
&lt;/pre&gt;

	&lt;p&gt;In this example, I am using the C# syntax that uses the
	Objective-C style to highlight what we are doing, but you
	could just have written this as:

	&lt;pre class="code-csharp"&gt;
view.AddObserver (
	this, new NSString ("bounds"),
	NSKeyValueObservingOptions.New, IntPtr.Zero);
&lt;/pre&gt;

	&lt;p&gt;What the above code does is to add an observer on the
	"view" object, and instructs it to notify this object when the
	"bounds" property changes.

	&lt;p&gt;To receive notifications, you need to override the
	ObserveValue method in your class:

&lt;pre class="code-csharp"&gt;
public override
void ObserveValue (NSString keyPath, NSObject ofObject,
			NSDictionary change, IntPtr context)
{
    var str = String.Format (
	"The {0} property on {1}, the change is: {2}",
        keyPath, ofObject, change.Description);

    label.Text = str;
    label.Frame = ComputeLabelRect ();
}
&lt;/pre&gt;

	&lt;p&gt;This is what the app shows if you rotate your phone:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/5a85f5d0.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;The complete sample has been uploaded
	to &lt;a href="https://github.com/xamarin/monotouch-samples/tree/master/KeyValueObserving"&gt;GitHub&lt;/a&gt;.
	
</description>
      <link>http://tirania.org/monomac/archive/2012/Apr-19.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Apr-19.html</guid>
      <pubDate>Thu, 19 Apr 2012 22:12:00 -0500</pubDate>
    </item>
    <item>
      <title>Call for Comments: Strongly Typed Notifications</title>
      <description>
	&lt;p&gt;I am adding support for strongly typed notifications to
	MonoTouch and MonoMac.   The idea behind this is to take
	guesswork, trips to the documentation and trial and error from
	using notifications on iOS and MacOS.

	&lt;p&gt;The process is usually: (a) find the right notification;
	(b) look up apple docs to see when the notification is posted;
	(c) look up each of the keys used to retrieve the data from
	the dictionary.   
	
	&lt;p&gt;Currently, listening to a notification for a
	keyboard-will-be-shown notification looks like this in
	MonoTouch:

&lt;pre&gt;
void DoSomething (
	UIViewAnimationCurve curve,
	double               duration,
	RectangleF           frame)
{
	// do something with the above
}

var center = NSNotificationCenter.DefaultCenter;
center.AddObserver (UIKeyboard.WillShowNotification, PlaceKeyboard);

[...]

void PlaceKeyboard (NSNotification notification)
{
    // Get the dictionary with the interesting values:
    var dict = notification.UserInfo;

    // Extract the individual values
    var animationCurve = (UIViewAnimationCurve)
	(dict [UIKeyboard.AnimationCurveUserInfoKey] as NSNumber).Int32Value;
    double duration =
	(dict [UIKeyboard.AnimationDurationUserInfoKey] as NSNumber).DoubleValue;
    RectangleF endFrame =
	(dict [UIKeyboard.FrameEndUserInfoKey] as NSValue).RectangleFValue;

    DoSomething (animationCurve, duration, endFrame)
}
&lt;/pre&gt;

	&lt;p&gt;Currently we map the Objective-C constant 
	"FooClassNameNotification" into the C# class "Foo" as the member
	"NameNotification" of type NSString.

	&lt;p&gt;What we want to do is to expose the notifications as
	strongly typed C# events.   This will provide auto-complete
	support in the IDE to produce the lambdas or helper methods,
	auto-complete for all the possible properties of the
	notification, strong types for the data provided and
	live documentation for the values in the notification.

	&lt;p&gt;This means that the above code would instead be written
	like this:

&lt;pre&gt;
var center = NSNotificationCenter.DefaultCenter;
center.Keyboard.WillShowNotification += PlaceKeyboard;

void PlaceKeyboard (object sender, KeyboardShownEventArgs args)
{
    DoSomething (args.AnimationCurve, args.Duration, args.EndFrame);
}
&lt;/pre&gt;
	&lt;p&gt;The question is where should these notifications be exposed
	in the API?   In the example above we do this by the event
	"WillShowNotification" on a class "Keyboard" inside the
	"NSNotificationCenter".   We have a few options for this.

	&lt;p&gt;We could host the notification in the class that defines
	the notification, but we would have to come up with a naming
	scheme to avoid the name clash with the existing NSString constant:

&lt;pre&gt;
class UIKeyboard {
    public NSString WillShowNotification { get; }

    // replace "Notification" with the class name:
    public event EventHandler&lt;KeyboardShowEventArgs&gt; WillShowKeyboard;

    // prefix the event:
    public event EventHandler&lt;KeyboardShowEventArgs&gt; KeyboardWillShow;

    // plain, does not work on all types though:
    public event EventHandler&lt;KeyboardShowEventArgs&gt; WillShow;
}

// Consumer code would be one of:

UIKeyboard.WillShowKeyboard += handler;
UIKeyboard.KeyboardWillShow += handler;
UIKeyboard.WillShow += handler;
&lt;/pre&gt;

	&lt;p&gt;Another option is to add everything into
	NSNotificationCenter:

&lt;pre&gt;
class NSNotificationCenter {
	// Existing implementation

    public event EventHandler&lt;KeyboardShowEventArgs&gt; UIKeyboardWillShow;

    // Another 141 events are inserted here.
}

// Consumer code would be:

NSNotificationCenter.DefaultCenter.UIKeyboardWillShow += handler;
&lt;/pre&gt;

	&lt;p&gt;Another option is to partition the notifications based on
	their natural host, this is my personal favorite, but could be
	harder to find with the IDE using code completion:

&lt;pre&gt;
class NSNotificationCenter {
    public static class Keyboard {
        public static event EventHandler&lt;KeyboardShowEventArgs&gt; WillShow;
    }
}

// Consumer code would be:
NSNotificationCenter.Keyboard.WillShow += handler;
&lt;/pre&gt;

	&lt;p&gt;All of these proposals have one potential problem: they
	would all assume that all of these interesting notifications
	are always posted into the NSNotificationCenter.DefaultCenter.

	&lt;p&gt;Apple's documentation does not seem to suggest that any of the
	iOS notifications are posted anywhere but the DefaultCenter.
	I could not find on GitHub any code that would use anything
	but the DefaultCenter.

	&lt;p&gt;On MacOS the InstantMessage framework posts notifications
	to its own notification center.   We could just bind those
	events to this specific NSNotificationCenter.   

	&lt;p&gt;Thoughts?
</description>
      <link>http://tirania.org/monomac/archive/2012/Apr-12.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Apr-12.html</guid>
      <pubDate>Thu, 12 Apr 2012 21:06:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoMac Updates</title>
      <description>
	&lt;p&gt;We have been hard at work at improving the MonoMac API to
	allow .NET developers to create native Mac applications using
	C#, F#, IronPython or their favorite .NET language.

	&lt;p&gt;There are couple of goodies coming on our next release of
	MonoMac: our Lion support is shapping up and we have been
	dogfooding this ourselves with our own apps.

	&lt;p&gt;One of our sample apps, a simple front-end to the Mono
	Documentation backend is now complete enough that we are going
	to deprecate the Gtk+ version of it and replace it with the
	native version of it.

	&lt;p&gt;MacDoc now has several new features

	&lt;p&gt;&lt;b&gt;Apple documentation integration:&lt;/b&gt; MacDoc will now
	download the Apple docs if they are not available and
	blend its contents with our documentation and replace the
	Objective-C samples with C# samples.   Amazing!

	&lt;p&gt;&lt;b&gt;Full text indexing:&lt;/b&gt; the documentation browser is
	using Lucene to index all of the contents and allow you to
	quickly find the materials that you are looking for.

	
	&lt;center&gt;
	&lt;img src="http://tirania.org/s/69c08dbc.png"&gt;
	&lt;/center&gt;
	
	&lt;p&gt;&lt;b&gt;Conceptual Index:&lt;/b&gt; in addition to the full text
	search, we generate a curated version of the APIs that are
	useful for performing search-as-you-type in the documentation
	browser.  This is useful to find APIs by class, by method name
	and also by Objective-C selector.   This means that you can
	now search for Objetive-C selectors in our documentation, and
	you will get the actual mapping to the C# method.

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/1cb8b516.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;Supports Lion documents, saved state and
	bookmarks.

	&lt;p&gt;We extended the ECMA XML format so it now renders
	images for our docs:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/94a15a6a.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;The source code is available now
	in &lt;a href="https://github.com/mono/monomac/tree/master/samples/macdoc"&gt;GitHub&lt;/a&gt;
	and will be shipping in the upcoming MonoDevelop 2.8.8 release.
</description>
      <link>http://tirania.org/monomac/archive/2012/Mar-06.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Mar-06.html</guid>
      <pubDate>Tue, 06 Mar 2012 21:34:00 -0500</pubDate>
    </item>
    <item>
      <title>Bubbles</title>
      <description>
	&lt;p&gt;Recently one of our customers asked about how to implement
	a conversation display similar to the iOS SMS/Messages
	display.   You can find
	the &lt;a href="https://github.com/xamarin/monotouch-samples/tree/master/BubbleCell"&gt;BubbleCell
	sample&lt;/a&gt; in our Github repository.

	&lt;p&gt;This is what the conversation looks like:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/c38c418a.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;To implement this, I used iOS's UITableView as it already
	provides a lot of the functionality that we need for this.
	What I did was to write a custom UITableViewCell that can
	render bubbles with their text.

	&lt;p&gt;I wrote both a MonoTouch.Dialog Element that you can host
	in your DialogViewController as well as a custom
	UITableCellView which can be reused by those using
	UITableViews directly.

	&lt;p&gt;This is how you could populate the initial discussion
	inside MonoTouch.Dialog:

	&lt;pre class="code-csharp"&gt;
Section chat;
var root = new RootElement ("Chat Sample") {
  (chat = new Section () {
    new ChatBubble (true, "This is the text on the left, what I find fascinating about this is how many lines can fit!"),
    new ChatBubble (false, "This is some text on the right"),
    new ChatBubble (true, "Wow, you are very intense!"),
    new ChatBubble (false, "oops"),
    new ChatBubble (true, "yes"),
  })
};&lt;/pre&gt;

	&lt;p&gt;And this is how you would add a new element to the
	conversation:

	&lt;pre class="code-csharp"&gt;
chat.Section.Add (
  new ChatBubble (false, "I want more cat facts"));&lt;/pre&gt;

&lt;h2&gt;Implementation&lt;/h2&gt;

	&lt;p&gt;Bubble rendering is implemented in Bubble.cs and contains
	both the UITableViewCell as well as the element.   It follows
	the pattern for creating UITableViewCells that
	I &lt;a href="http://tirania.org/monomac/archive/2011/Jan-18.html"&gt;documented before&lt;/a&gt;.

	&lt;p&gt;Each cell is made up of two views: one contains a
	UIImageView that paints the bubble and the other one contains
	the text to render inside the bubble.

	&lt;p&gt;This is what the two bubbles images look like:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/dba416d6.png"&gt;
	&lt;/center&gt;
	
	&lt;p&gt;We load these using UIImage.FromFile and then use the iOS
	5.0 &lt;a href="http://iosapi.xamarin.com/?link=M%3aMonoTouch.UIKit.UIImage.CreateResizableImage(MonoTouch.UIKit.UIEdgeInsets)"&gt;UIImage.CreateResizableImage&lt;/a&gt;
	method to create a UIImage that can be stretched on demand.
	To create the resizable image we need to tell
	CreateResizableImage the region of the image that can be
	stretched.  Anything outside of the UIEdgeInset will be kept
	as-is:

	&lt;pre class="code-csharp"&gt;
left = bleft.CreateResizableImage (new UIEdgeInsets (10, 16, 18, 26));
right = bright.CreateResizableImage (new UIEdgeInsets (11, 11, 17, 18));&lt;/pre&gt;

	&lt;p&gt;This will stretch the region highlighted in red, while
	rendering the external border as-is:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/bstretch.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;With the above code, the image will be rendered in a
	variety ways depending on the Frame that is assigned to the
	UIImageView that hosts our resizable UIImage:

	&lt;center&gt;
	&lt;img src="http://tirania.org/s/ff8a3a6c.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;The only remaining interesting bit in the code is to
	configure our UILabel properly.   We want to set its
	BackgroundColor to UIColor.Clear to avoid painting the
	background in a solid color and we also specify that the text
	should be word-wrapped if it does not fit in a single line:

	&lt;pre class="code-csharp"&gt;
label = new UILabel (rect) {
  LineBreakMode = UILineBreakMode.WordWrap,
  Lines = 0,
  Font = font,
  BackgroundColor = UIColor.Clear
};
	&lt;/pre&gt;

	&lt;p&gt;Finally in our LayoutSubViews method we must compute the
	proper sizes for the bubbles and the text that goes in them.
	I made it so the bubbles did not take the entire space in a
	row.   Instead they take 70% of the row to give a similar
	effect to the rendering of the iOS messages UI.     The code
	is pretty straight-forward:

	&lt;pre class="code-csharp"&gt;
public override void LayoutSubviews ()
{
  base.LayoutSubviews ();
  var frame = ContentView.Frame;
  var size = GetSizeForText (this, label.Text) + BubblePadding;
  imageView.Frame = new RectangleF (new PointF (isLeft ? 10 : frame.Width-size.Width-10, frame.Y), size);
  view.SetNeedsDisplay ();
  frame = imageView.Frame;
  label.Frame = new RectangleF (new PointF (frame.X + (isLeft ? 12 : 8), frame.Y + 6), size-BubblePadding);
}
	&lt;/pre&gt;
	
</description>
      <link>http://tirania.org/monomac/archive/2012/Jan-30.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2012/Jan-30.html</guid>
      <pubDate>Mon, 30 Jan 2012 18:22:00 -0500</pubDate>
    </item>
    <item>
      <title>Styling your controls in MonoTouch on iOS 5</title>
      <description>
	&lt;p&gt;Starting with iOS 5 it is possible to more easily style
	your UIViews.   Apple did this by exposing a new set of
	properties on most views that can be tuned.   For example, to
	configure the TintColor of a UISlider, you would write:

&lt;pre&gt;

var mySlider = new UISlider (rect);
mySlider.ThumbTintColor = UIColor.Red;

&lt;/pre&gt;
	

	&lt;p&gt;You can also set the color globally for all instances of
	UISlider, you do this by assigning the styling attributes on
	the special property "Appearance" from the class you want to
	style. 
	
	&lt;p&gt;The following example shows how to set the Tint color for all
	UISliders:

&lt;pre&gt;

	UISlider.Appearance.ThumbTintColor = UIColor.Red;

&lt;/pre&gt;

	&lt;p&gt;It is of course possible to set this on a per-view way, 

	&lt;p&gt;The first time that you access the "Appearance" static
	property on a stylable class a UIAppearance proxy will be
	created to host the style changes that you have requested and
	will apply to your views.

	&lt;p&gt;In Objective-C the Appearance property is untyped.   With
	MonoTouch we took a different approach, we created a strongly
	typed UIXxxxAppearance class for each class that supports
	styling.    Our generated UIXxxxxAppearance class is strongly
	typed, which allows users to use intellisense to easily
	discover which properties are avaialble for styling.

	&lt;p&gt;We also created a hierarchy that reflects the inherited
	appearance properties, this is the class hierarchy for the
	&lt;a href="http://docs.go-mono.com/index.aspx?link=T%3aMonoTouch.UIKit.UISlider%2bUISliderAppearance"&gt;UISLider.UISliderAppearance&lt;/a&gt;
	class:

&lt;center&gt;
&lt;img src="http://tirania.org/s/87cf5019.png"&gt;
&lt;/center&gt;

	&lt;p&gt;The properties exposed by UISlider for example are:

&lt;pre&gt;
public class UISliderAppearance {
	public virtual UIColor BackgroundColor {
		get;
		set;
	}
	public virtual UIColor MaximumTrackTintColor {
		get;
		set;
	}
	public virtual UIColor MinimumTrackTintColor {
		get;
		set;
	}
	public virtual UIColor ThumbTintColor {
		get;
		set;
	}
}
&lt;/pre&gt;

	&lt;p&gt;MonoTouch also introduced support for styling your controls
	only when they are hosted in a particular part of the
	hierarchy.   You do this by calling the static method
	AppearanceWhenContainedIn which takes a variable list of
	types, it works like this:

&lt;pre&gt;
var style = UISlider.AppearanceWhenContainedIn (typeof (SalesPane), typeof (ProductDetail));
style.ThumbTintColor = UIColor.Red;
&lt;/pre&gt;

	&lt;p&gt;In the above sample the style for the ThumbTintColor will
	be red, but only for the UISliders contained in ProductDetail
	view controllers when those view controllers are being hosted
	by a SalesPane view controller.  Other UISliders will not be
	affected.

	&lt;p&gt;Both the Appearance static property and the
	AppearanceWhenContainedIn static method have been surfaced on
	every UIView that supports configuring its style.    Both of
	them return strongly typed classes that derive from
	UIAppearance and expose the exact set of properties that can
	be set.

	&lt;p&gt;This is different from the weakly typed Objective-C API
	which makes it hard to discover what can be styled.
</description>
      <link>http://tirania.org/monomac/archive/2011/Oct-14.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Oct-14.html</guid>
      <pubDate>Fri, 14 Oct 2011 22:38:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoTouch 5.0 is out</title>
      <description>
	&lt;p&gt;Yesterday &lt;a href="http://blog.xamarin.com/2011/10/12/monotouch-5-with-ios-5-support/"&gt;we
	released MonoTouch 5.0&lt;/a&gt;, the companion to Apple's iOS 5.0
	release.

	&lt;p&gt;Apple tends to ship Objective-C APIs that are configured
	through an NSDictionary instance containing configuration
	keys.  With MonoTouch 5.0, we continued our work
	to &lt;a href="http://tirania.org/monomac/archive/2010/Dec-01.html"&gt;improve
	over NSDictionary-based bindings&lt;/a&gt; by creating
	strongly-typed versions of those APIs.

	&lt;p&gt;In the next couple of days, I will be sharing some of the
	new features in iOS 5.0 and how to take advantage of those
	using C#.

	&lt;p&gt;Meanwhile, our documentation team has produced an amazing
	&lt;a href="http://docs.xamarin.com/ios/tutorials/Introduction_to_iOS_5"&gt;Introduction
	to iOS 5.0 for C# developers&lt;/a&gt; and put together some samples
	showing how to use some of the new features in iOS 5:

	&lt;ul&gt;
		&lt;li&gt;&lt;a href="http://docs.xamarin.com/@api/deki/files/323/=Storyboard.zip"&gt;Storyboard&lt;/a&gt;:
		shows how to use Storyboards from C# and showcases the
		integration between Xcode 4 and MonoDevelop 2.8

		&lt;li&gt;&lt;a href="http://docs.xamarin.com/@api/deki/files/320/=CoreImage.zip"&gt;CoreImage&lt;/a&gt;:
		shows our bubilicious strongly-typed API for
		CIFilters, it is in my opinion, a huge usability
		upgrade over the NSDictionary-based approach. 
		
		&lt;li&gt;&lt;a href="http://docs.xamarin.com/@api/deki/files/321/=iCloud.zip"&gt;iCloud&lt;/a&gt;:
		Basic iCloud use.

		&lt;li&gt;&lt;a href="http://docs.xamarin.com/@api/deki/files/324/=Twitter.zip"&gt;Twitter&lt;/a&gt;:
		Post new tweets and query twitter for data.

		&lt;li&gt;&lt;a href="http://docs.xamarin.com/@api/deki/files/322/=Newsstand.zip"&gt;Newsstand&lt;/a&gt;:
		A complete sample showing how you can integrate with
		the new Newsstand APIs to publish your own
		periodicals.    We wont be submitting this sample for
		the Apple Design Awards, but it shows how to use the framework.
	&lt;/ul&gt;

	
</description>
      <link>http://tirania.org/monomac/archive/2011/Oct-13.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Oct-13.html</guid>
      <pubDate>Thu, 13 Oct 2011 16:28:00 -0500</pubDate>
    </item>
    <item>
      <title>TestFlight support in MonoDevelop</title>
      <description>
	&lt;p&gt;We have just released for &lt;a href="http://docs.xamarin.com/ios/tutorials/TestFlight_Support"&gt;TestFlight support&lt;/a&gt; in
	MonoDevelop.

	&lt;p&gt;This makes it simpler for developers to deploy their Ad-Hoc
	builds directly to Testflight, we added a "Publish to
	TestFlight" option:

	&lt;center&gt;
	&lt;img src="http://docs.xamarin.com/@api/deki/files/271/=testflight-1.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;The first time you upload to TestFlight you must provide
	your authentication tokens:

	&lt;center&gt;
	&lt;img src="http://docs.xamarin.com/@api/deki/files/268/=testflight-4.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;And after that, the IDE takes care of the rest:

	&lt;center&gt;
	&lt;img src="http://docs.xamarin.com/@api/deki/files/266/=testflight-6.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;This is built on top of our
	enhanced &lt;a href="http://docs.xamarin.com/ios/tutorials/IPA_Support_-_Ad_Hoc_and_Enterprise_Deployment"&gt;IPA
	Packaging support&lt;/a&gt; in the same release.
</description>
      <link>http://tirania.org/monomac/archive/2011/Sep-29.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Sep-29.html</guid>
      <pubDate>Thu, 29 Sep 2011 14:12:00 -0500</pubDate>
    </item>
    <item>
      <title>Sales Force app built with MonoTouch</title>
      <description>
	&lt;p&gt;I do not blog very often about apps built with MonoTouch,
	but &lt;a href="http://www.justenough.com/NetSuite/MobileSFA/"&gt;this
	application&lt;/a&gt; is drop-dead gorgeous.

	&lt;p&gt;It is a tool designed to be used by the sales force of a
	company.

	&lt;p&gt;You can download the app from the Apple AppStore and try it
	on "demo" mode.   What I love about this application is how
	they took advantage of UIKit and CoreAnimation to create a
	beautiful enterprise app.   It does not stop there, they use
	everything iOS has to offer:

	&lt;center&gt;
	&lt;img src="http://a3.mzstatic.com/us/r1000/063/Purple/f5/ed/83/mzl.gtaqidjm.480x480-75.jpg"&gt;
	&lt;p&gt;
	&lt;img src="http://a2.mzstatic.com/us/r1000/061/Purple/37/da/11/mzl.wkykqmxl.480x480-75.jpg"&gt;
	&lt;/center&gt;

	&lt;p&gt;Enterprise software has a reputation for being hostile to
	end-users.  This shows that you can create great end-user
	software for users in the enterprise.  If you were looking for
	inspiration for your own enterprise apps, this is the app to
	look for.

	
</description>
      <link>http://tirania.org/monomac/archive/2011/Aug-12.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Aug-12.html</guid>
      <pubDate>Fri, 12 Aug 2011 20:28:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoMac add-in for MonoDevelop</title>
      <description>
	&lt;p&gt;After a small hiatus we are back.

	&lt;p&gt;If you have been using MonoMac to build MacOS applications,
	we have just released an update to the MonoDevelop.MonoMac
	add-in that should fix the problem with packaging your
	applications on Lion.

	&lt;p&gt;This update just contains a critical fix and delivers the
	add-in to all three MonoDevelop platforms in use today: our
	stable MonoDevelop 2.4, the 2.6beta3 and for the fearless
	among you MonoDevelop/master.

	&lt;p&gt;This was just the first step in maintaining the add-in.   I
	had to sort out the build setup for all three branches and the
	pipeline to deliver the updates.   Now that I got things in
	place, I will be able to fix some of the other problems that
	have been reported.

	&lt;p&gt;If you are running into problems with MonoMac, please file
	your bugs at the new home for the Mono bug reports
	at &lt;a href="http://bugzilla.xamarin.com"&gt;http://bugzilla.xamarin.com&lt;/a&gt;.
	
</description>
      <link>http://tirania.org/monomac/archive/2011/Aug-03.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Aug-03.html</guid>
      <pubDate>Wed, 03 Aug 2011 21:40:00 -0500</pubDate>
    </item>
    <item>
      <title>Glass button for iPhone</title>
      <description>
	&lt;p&gt;Since iOS does not provide a default glossy button
	implementation I wrote my own, based mostly on looking at a
	screenshot of Apple's own.

	&lt;p&gt;Some folks have been using
	the &lt;a href="http://conceptdev.blogspot.com/2010/08/uiglassbutton-generator-in-monotouch.html"&gt;UIGlassButton
	generator&lt;/a&gt;, but I have wanted for a while to have this
	functionality avaialble at runtime, and not depend on
	pre-generated images, these are created at runtime, and behave
	just like a regular button:

	&lt;center&gt;
	&lt;img src="http://tirania.org/pictures/mt-glass-button.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;You can
	find &lt;a href="https://github.com/migueldeicaza/MonoTouch.Dialog/blob/master/MonoTouch.Dialog/Utilities/GlassButton.cs"&gt;my
	implementation&lt;/a&gt; as part
	of &lt;a href="https://github.com/migueldeicaza/MonoTouch.Dialog/blob/master/MonoTouch.Dialog"&gt;MonoTouch.Dialog&lt;/a&gt;
	on github.

	&lt;p&gt;This is how you would use it, and how you can customize
	some of its elements:

	&lt;pre class="code-csharp"&gt;
	var b = new GlassButton (bounds) {
		Font = UIFont.BoldSystemFontOfSize (22),
		NormalColor = UIColor.Green,
		HighlightedColor = UIColor.Red
	};
	b.SetTitle ("Dismiss", UIControlState.Normal);

	container.AddSubview (b);
	&lt;/pre&gt;
</description>
      <link>http://tirania.org/monomac/archive/2011/Apr-08.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Apr-08.html</guid>
      <pubDate>Fri, 08 Apr 2011 14:19:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoTouch 4.0</title>
      <description>
	&lt;p&gt;&lt;img src="http://tirania.org/pictures/vintage-monotouch-logo.png"
	align="right"&gt;We just released MonoTouch 4.0, a product to build iOS
	applications using C# and .NET.  We also released our new
	&lt;a href="http://tirania.org/blog/archive/2011/Apr-06.html"&gt;Mono
	for Android&lt;/a&gt; product.

&lt;h2&gt;New in MonoTouch 4.0&lt;/h2&gt;

	&lt;p&gt;MonoTouch 4.0 is a major upgrade to our product as it
	upgrades the Mono runtime engine from the old, trusted and
	friendly Mono 2.6 to the latest and greatest &lt;a href="http://www.mono-project.com/Release_Notes_Mono_2.10"&gt;Mono
	2.10&lt;/a&gt; core, these are some of the new features available as
	part of this upgrade:

	&lt;ul&gt;
		&lt;li&gt;Parallel Frameworks for C#: Great APIs for
		building multi-threaded software.  Not only this is
		great for iPad 2 users and developers, but it also
		simplifies just plain multi-threaded programming by
		exposing Futures, Tasks and Parallel LINQ to the
		developer.

		&lt;li&gt;LLVM Compiler Support: In addition to the fast
		Mono compilation engine, MonoTouch can now also use
		LLVM to create optimized builds.   When you build
		MonoTouch applications using LLVM your executables
		will run faster, they will be smaller, and you can
		optionally opt into generating the nimbler ARMv7 or
		Thumb code (fat binaries are also supported).

		&lt;p&gt;&lt;b&gt;Example:&lt;/b&gt; My
		own &lt;a href="http://tirania.org/tweetstation/"&gt;TweetStation
		distribution&lt;/a&gt; went from 8 megs to 6 megs using
		Thumb + ARMv7 support.  A very significant gain.

		&lt;li&gt;C# 4.0 and .NET 4.0: This release comes with the
		latest incarnation of the C# language as well as
		exposing the new .NET 4.0 APIs (many new functional
		constructs make for nicer looking code, like all the
		IEnumerable&lt;Foo&gt; enabled-methods in System.IO).

		&lt;p&gt;There is one important limitation: C# 4.0 dynamic
		support is not functional, since it requires dynamic
		code generation to work.

		&lt;li&gt;Upgraded WCF stack:   We still consider this a
		preview of the full WCF but has been expanded
		significantly.   

		&lt;li&gt;All new iOS 4.3 APIs have been exposed.

		&lt;li&gt;NSDecimal, NSDecimalNumber are now exposed (mostly
		for the sake of CorePlot :-)

		&lt;li&gt;Many new convenience APIs have been introduced.
	&lt;/ul&gt;

	&lt;p&gt;For a full detailed list of changes,
	see &lt;a href="http://monotouch.net/Releases/MonoTouch_4/MonoTouch_4.0.0"&gt;our
	MonoTouch 4.0 Release Notes&lt;/a&gt;.
	
&lt;h2&gt;Resources&lt;/h2&gt;

	&lt;p&gt;The best source of information on parallel programming with
	Parallel FX is the
	free &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=86b3d32b-ad26-4bb8-a3ae-c1637026c3ee&amp;displaylang=en"&gt;Patterns
	for Parallel Programming: Understanding and Applying Parallel
	Patterns with the .NET Framework 4&lt;/a&gt;.

	&lt;p&gt;This is a brilliant document.   Whether you use .NET or
	not, this is a recommended reading for everyone.

	&lt;p&gt;In addition to
	the &lt;a href="http://www.amazon.com/dp/047063782X/ref=as_li_ss_til?tag=tiraniaorg-20&amp;camp=213381&amp;creative=390973&amp;linkCode=as4&amp;creativeASIN=047063782X&amp;adid=12Z07C36B4TXR7Y4QRM4&amp;"&gt;Programming
	iPhone with MonoTouch book&lt;/a&gt; there are two new books about
	to hit the
	shelves &lt;a href="http://www.amazon.com/gp/product/1430231742/ref=as_li_ss_tl?ie=UTF8&amp;tag=tiraniaorg-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1430231742"&gt;Developing
	C# Apps for iPhone and iPad using MonoTouch: iOS Apps
	Development for .NET Developers&lt;/a&gt;: an incredibly in-depth
	book from Brian Costanich that I have had the privilege to
	read in advance.  This book will come out in only 3 weeks.

	&lt;p&gt;If you are more of a hands-on kind of guy, later in the
	year, Mike
	Bluestein's &lt;a href="http://www.amazon.com/gp/product/0321719921/ref=as_li_ss_tl?ie=UTF8&amp;tag=tiraniaorg-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0321719921"&gt;Learning
	MonoTouch: A Hands-On Guide to Building iPhone and iPad
	Applications with C# and .NET&lt;/a&gt; is coming out.

&lt;h2&gt;Next Steps&lt;/h2&gt;

	&lt;p&gt;We are currently hard at work to add support to MonoDevelop
	to work with the new XCode 4.

	&lt;p&gt;With XCode 4, Apple removed Interface Builder as a
	standalone tool.   We should have a beta in a couple of weeks
	of the solution we came up with.
</description>
      <link>http://tirania.org/monomac/archive/2011/Apr-06.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Apr-06.html</guid>
      <pubDate>Wed, 06 Apr 2011 16:20:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoMac 1.0 is out</title>
      <description>
	&lt;p&gt;&lt;a href="http://tirania.org/blog/archive/2010/Apr-19.html"&gt;Almost
	a year ago&lt;/a&gt; we started building a set of Mono bindings for
	building native MacOS X applications.

	&lt;p&gt;Our original goals were modest: bind enough of AppKit that
	you could build native desktop applications for OSX using C#
	or your favorite .NET language.  We leveraged a lot of the
	code that we built for MonoTouch our binding to the CocoaTouch
	APIs.

	&lt;p&gt;During the year, the project picked up steam, we got plenty
	of contributions to MonoMac and grew beyond the original
	conservative goals.

	&lt;p&gt;In a year we:

	&lt;ul&gt;
		&lt;li&gt;Created a beautiful library
		that &lt;a href="http://www.mono-project.com/MonoMac#Background"&gt;blends
		the worlds of C# and MacOS X&lt;/a&gt; APIs.

		&lt;li&gt;&lt;a href="http://mjhutchinson.com/journal/2010/06/09/monomac_in_monodevelop"&gt;Created
		a MonoDevelop add-in&lt;/a&gt; that helps developers get
		started with Mac development in minutes.

		&lt;li&gt;Integrated the MonoDoc system into MonoDevelop, to
		provide developers with documentation on the flight as
		they type their code.  Detailed method information,
		parameter use and type information is available as you
		type your code in unobtrusive windows. 

		&lt;li&gt;&lt;a href="http://www.mono-project.com/MonoMacPackager"&gt;Created
		a packager&lt;/a&gt; that turns your programs into
		self-contained OSX Packages with no external
		dependencies on Mono and can be deployed to the Apple
		App Store.

		&lt;li&gt;Created a linker that lets you strip out any
		functionality your application might not need to
		reduce your executable size.
		
		&lt;li&gt;Created
		a &lt;a href="http://lists.ximian.com/pipermail/mono-osx/"&gt;great
		community of developers&lt;/a&gt; that love C#, .NET and
		MacOS.  For some of us, this is a step closer to
		heaven.

		&lt;li&gt;Created
		a &lt;a href="https://github.com/mono/monomac/tree/master/samples"&gt;big
		pool of samples&lt;/a&gt; for developers to learn from, and
		for us to exercise the API and ensure that the
		resulting library was a delight to use.

		&lt;li&gt;Created
		various &lt;a href="http://www.mono-project.com/MonoMac#Tutorials"&gt;tutorials&lt;/a&gt;
		on how to build applications with C# on the Mac.

		&lt;li&gt;Built
		an &lt;a href="http://mono.ximian.com/monomac-docs/"&gt;online
		documentation mash-up&lt;/a&gt; between our API and Apple's
		web documentation
	&lt;/ul&gt;
	
	&lt;p&gt;Some statistics about the MonoMac binding:

	&lt;ul&gt;
		&lt;li&gt;1,155 C# classes and 31 C# structures

		&lt;li&gt;376 enumerations

		&lt;li&gt;123 C# delegate data types

		&lt;li&gt;16,556 methods, properties and events exposed
	&lt;/ul&gt;

	&lt;p&gt;In addition to that,
	MonoMac &lt;a href="http://mono.ximian.com/monomac-docs/MonoMac.OpenGL"&gt;bundles
	a modified version&lt;/a&gt; of the
	amazing &lt;a href="http://www.opentk.com/"&gt;OpenTK 1.0&lt;/a&gt;.  We
	took the liberty (and by "we" I mean, the amazing Kenneth
	Pouncey) of fine-tuning the implementation for MonoMac use.
	
&lt;h2&gt;Getting MonoMac 1.0&lt;/h2&gt;

	&lt;p&gt;If you already have MonoDevelop installed, just update your
	MonoMac Add-In.   If you do not have MonoDevelop installed,
	follow
	our &lt;a href="http://www.mono-project.com/MonoMac#Obtaining_MonoMac"&gt;friendly
	instructions&lt;/a&gt;. 

&lt;h2&gt;Contributors&lt;/h2&gt;

	&lt;p&gt;MonoMac would not have been possible without the help of
	our great contributors, this is the team:

	&lt;p&gt;Main bindings:
	&lt;ul&gt;
		&lt;li&gt;Geoff Norton
		&lt;li&gt;Miguel de Icaza
		&lt;li&gt;Jonathan Pryor
		&lt;li&gt;Michael Hutchinson
	&lt;/ul&gt;

	&lt;p&gt;Contributors:
	&lt;ul&gt;
		&lt;li&gt;Alexander Shulgin (WebKit DOM)
		&lt;li&gt;James Clancey (AppKit contributions)
		&lt;li&gt;Kenneth Pouncey (API, samples)
		&lt;li&gt;Maxi Combina (WebKit events, sample)
		&lt;li&gt;Regan Sarwas (PdfKit, ImageKit, NSColor, NSGradient, NSBezierPath, samples)	
		&lt;li&gt;Ashok Gelal (CoreWlan)
	&lt;/ul&gt;

&lt;h2&gt;Next Steps&lt;/h2&gt;

	&lt;p&gt;What is great about doing a 1.0 release is that you know
	that there will be a 1.1 release, and a 1.2 release and a 2.0
	release.

	&lt;p&gt;This is our way of saying "thank you for waiting" and
	giving our users a chance to start building applications,
	knowing that we have battle tested MonoMac and it is being
	used in our own products now &lt;a href="#note"&gt;[1]&lt;/a&gt;.

	&lt;p&gt;We obviously will continue improving the API, adding more
	frameworks as time goes by, but we will also be working with
	other communities to expand MonoDevelop's language support,
	create more templates for languages like F#, IronRuby,
	IronPython and UnityScript.

	&lt;p&gt;Although we have a great start for documentation, we hope
	that contributors will take advantage of a new web-based wiki
	and collaboration tool that we are building to improve the
	docs and help us make MonoMac's documentation the best.

	&lt;p&gt;Hopefully, we will also get more samples contributed to
	MonoMac and we will see a new wave of tutorials and we will
	see fascinating discussions on how to build better software
	while enjoying every second of it. 

	&lt;p&gt;&lt;a name="note"&gt;[1]&lt;/a&gt; (MonoDevelop 2.6 will be using
	MonoMac for its native dialog boxes).
</description>
      <link>http://tirania.org/monomac/archive/2011/Mar-17.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Mar-17.html</guid>
      <pubDate>Thu, 17 Mar 2011 19:16:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoMac hotfix</title>
      <description>
	&lt;p&gt;&lt;a href="https://github.com/hbons"&gt;Hylke Bons&lt;/a&gt; warned us
	of a limitation in our MonoMac packager so we are issuing a
	new MonoMac refresh that fixes various bugs:

	&lt;ul&gt;
	&lt;li&gt;Supports using Mono.Posix.dll in packaged bundles.
	&lt;li&gt;Supports using System.Drawing in packaged bundles.
	&lt;li&gt;Fixes various BCL P/Invokes problems (we forgot to ship
	the config file :-)
	&lt;li&gt;No longer requires Mono 2.8.1, works with any mono 2.8+
	&lt;/ul&gt;

	&lt;p&gt;Follow
	the &lt;a href="http://mono-project.com/MonoMac"&gt;standard
	instructions&lt;/a&gt; to update your MonoMac add-in.

	&lt;p&gt;Hylke then got
	his &lt;a href="https://github.com/hbons/SparkleShare/tree/master/SparkleShare/Mac/SparkleShare"&gt;native
	Mac client&lt;/a&gt;
	for &lt;a href="http://twitter.com/sparkleshare"&gt;SparkleShare&lt;/a&gt;
	(a DropBox-like system, but backed up by Git or any Git
	hosting sit) working as a bundle on OSX.
</description>
      <link>http://tirania.org/monomac/archive/2011/Feb-06.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Feb-06.html</guid>
      <pubDate>Sun, 06 Feb 2011 16:38:00 -0500</pubDate>
    </item>
    <item>
      <title>MonoMac Refresh!</title>
      <description>
	&lt;P&gt;We just pushed a new refresh
	of &lt;a href="http://www.mono-project.com/MonoMac"&gt;MonoMac&lt;/a&gt;.
	This release contains:

	&lt;ul&gt;
		&lt;li&gt;New complete bindings: QuartzComposer, CoreWlan,
		PdfKit, ImageKit and Addresbook.
		
		&lt;li&gt;AppKit: new classes: NSBezierPath, NSGradient;
		convenience methods for NSColor, NSTableView,
		NSMenuItem, and NSPasteboard.

		&lt;li&gt;CoreImage's CIVector and support in AppKit for
		CoreImage.

		&lt;li&gt;WebKit indexers and support for reporting user
		decisions. 
	&lt;/ul&gt;

	&lt;p&gt;In our shared core with MOnoTouch, these are the changes:
	
	&lt;ul&gt;
		&lt;li&gt;CoreGraphics: Support for transparency layers.

		&lt;li&gt;Foundation: API helpers to make NSIndexSet
		more pleasant to use; new methods to control the
		NSRunLoop; NSUrlProtocol and NSUrlProtocolClient
		classes. 

		&lt;li&gt;ObjCRuntime: Exposed the shared library loading
		code and convenience methods to pull constants from
		shared libraries.

		&lt;li&gt;KeyChain: expose new methods for common operations
		(managing internet passwords)

		&lt;li&gt;CoreAnimation: bound a few missing constants.

		&lt;li&gt;OpenGL: new CAOpenGLLayer type.

	&lt;/ul&gt;

	&lt;p&gt;Many new samples are now included with MonoTouch.  Kenneth
	has contributed various ported samples from the CoreAnimation
	book exercising the API, fixing it, and providing many samples
	for developers to get started.    We now ship 32 samples
	covering a wide range of Mac APIs.

	&lt;p&gt;Contributors to this release include: Geoff Norton,
	Alexander Shulgin, James Clancey, Maxi Combina, Regan Sarwas,
	Michael Hutchinson, Ashok Gelal and Miguel de Icaza.

	&lt;p&gt;Additionally, the first MonoMac app has hit the Mac
	AppStore!

	&lt;p&gt;Some small stats: MonoMac 0.4 was installed by 263
	developers, MonoMac 0.5 by 369 developers, and MonoMac 0.6
	(our last release) by 588.
</description>
      <link>http://tirania.org/monomac/archive/2011/Feb-02.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Feb-02.html</guid>
      <pubDate>Wed, 02 Feb 2011 23:55:00 -0500</pubDate>
    </item>
    <item>
      <title>First MonoMac App Hits the Apple AppStore</title>
      <description>
	&lt;p&gt;&lt;a href="http://site.yvansoftware.be/"&gt;Yvan Janssens&lt;/a&gt;
	(&lt;a href="http://twitter.com/yvanjanssens"&gt;@yvanjanssens&lt;/a&gt;)
	just wrote to let me know that
	&lt;a href="http://itunes.apple.com/us/app/iproxify-plus/id409373452?mt=12"&gt;iProxify
	Plush&lt;/a&gt;,
	his &lt;a href="http://www.mono-project.com/MonoMac"&gt;MonoMac-powered&lt;/a&gt;
	application, has been accepted for distribution on Apple's Mac
	AppStore.

	&lt;p&gt;This is an important development in the history of MonoMac,
	as someone has actually published a full executable based on
	the tools that we built (we have not tested this ourselves as
	we did not really have anything to publish).

	&lt;p&gt;It also means that we got all the details right to let
	people use C# to publish to the Mac AppStore: we do not take
	external dependencies, we bundle all of the Mono dependencies
	with the app and we follow all the relevant Apple rules for
	distribution. 

	&lt;p&gt;Congratulations to Yvan for his published app!

	
</description>
      <link>http://tirania.org/monomac/archive/2011/Jan-31.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Jan-31.html</guid>
      <pubDate>Mon, 31 Jan 2011 22:05:00 -0500</pubDate>
    </item>
    <item>
      <title>Patterns for Creating UITableViewCells</title>
      <description>
	&lt;p&gt;At one point or another, every UITableView programmer will
	outgrow the
	&lt;a href="http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7"&gt;default
	set of UITableViewCells styles&lt;/a&gt; available to them, and they
	will be forced to customize the cells to provide a better user
	experience.

	&lt;p&gt;The initial temptation of every lazy programmer like myself
	is to do the bare minimum amount of work to obtain the desired
	effect.   This path typically starts by realizing that you can
	add a subview to your cell, like this:

	&lt;pre class="code-csharp"&gt;
static UIImage logo = UIImage.FromFile ("logo.png");
UITableViewCell CreateCell ()
{
	var cell = new UITableViewCell (UITableViewCellStyle.Default, "key");
	var imageView = new UIImageView (logo) {
		Frame = new RectangleF (10, 10, 20, 20);
	};
	cell.ContentView.Add (imageView);
	return cell;
}
	&lt;/pre&gt;

	&lt;p&gt;Although the above code works, and you can get away with it
	for simple tasks, it does not take into consideration cell
	reuse.  UITableViews like to recycle cells on the screen which
	is fine as long as you do not need to use a different image on
	each cell, as all of a sudden, you will need to keep track of
	the imageView value.

	&lt;p&gt;In other cases, your GetCell method will get bloated with a
	lot of inside information about all possible customizations
	that you might have done in a previous instance, and you will
	have to undo those.   Apple's UICatalog sample is packed with
	code like that, and so
	is &lt;a href="https://github.com/migueldeicaza/monotouch-samples/blob/master/monocatalog/textfield.cs#L62"&gt;my
	port&lt;/a&gt; of the same code.

	&lt;p&gt;And that is just not a decent way of living.

	&lt;p&gt;You are miserable, your users are miserable and everyone
	around you is miserable.

	&lt;p&gt;My preferred pattern, which has worked better for me is to
	create a derived cell class that tracks all of my properties,
	and centralizes the management of updating the properties of
	my cell.

	&lt;p&gt;Assuming that my cell will render the contents of an object
	called "MyData", this is what my pattern looks like for
	custom UITableViewCells:

&lt;pre class="code-csharp"&gt;
//
// I create a view that renders my data, as this allows me to reuse
// the data rendering outside of a UITableViewCell context as well
//
public class MyDataView : UIView {
	MyData myData;

	public MyDataView (MyData myData)
	{
		Update (myData);
	}

	// Public method, that allows the code to externally update
	// what we are rendering.   
	public void Update (MyData myData)
	{
		this.myData = myData;
		SetNeedsDisplay ();
	}
}

//
// This is the actual UITableViewCell class
//
public class MyDataCell : UITableViewCell {
	MyDataView myDataView;

	public MyDataCell (MyData myData, NSString identKey) : base (UITableViewCellStyle.Default, identKey)
	{
		// Configure your cell here: selection style, colors, properties
		myDataView = new MyDataView (myData);
		ContentView.Add (myDataView);
	}

	public override void LayoutSubviews ()
	{
		base.LayoutSubviews ();
		myDataView.Frame = ContentView.Bounds;
		myDataView.SetNeedsDisplay ();
	}

	// Called by our client code when we get new data.
	public void UpdateCell (MyData newData)
	{
		myDataView.Update (newData);
	}
}
&lt;/pre&gt;

	&lt;p&gt;With the above pattern implemented, I can now add all of my
	view specific gadgetry into the MyDataView class, images,
	helper labels, or other views.

	&lt;p&gt;Then, the Update method needs to make sure that all of
	those extra views are updated when this method is invoked.
	All of the configuration for your cell needs to take place in
	this method, and nowhere else.

	&lt;p&gt;The client code that uses these views then looks like this:

&lt;pre class="code-csharp"&gt;
class MyTableViewDataSource : UITableViewDataSource {
	public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
	{
		MyData myData = Lookup (indexPath);

		var cell = tableView.DequeueReusableCell (key);
		if (cell == null)
			cell = new MyDataCell (myData);
		else 
			cell.UpdateCell (myData);
		return cell;
	}
&lt;/pre&gt;	

&lt;h3&gt;The Extra UIView&lt;/h3&gt;

	&lt;p&gt;You might be thinking that creating the extra UIView is not
	really worth the effort, as you likely only need to apply a
	few customizations, and you got already most of your bang for
	the buck by creating your custom UITableViewCell.

	&lt;p&gt;You would be right.

	&lt;p&gt;The reason for creating a custom UIView, is that there
	might come a time when you want to do some custom drawing in
	your cell.  Perhaps add a nice gradient on the background, or
	perhaps draw some shadows, or mix large fonts with small
	fonts.

	&lt;p&gt;It might be just a couple of small touch-ups, nothing too
	complicated, but just a little extra polish.   By using a
	custom UIView, you can now spice up your view just a tiny bit,
	by overriding the Draw method:

&lt;pre class="code-csharp"&gt;
public override void Draw (RectangleF rect)
{
	var context = UIGraphics.GetCurrentContext ();
	UIColor.White.SetColor ();
	context.FillRect (Bounds);
	context.DrawLinearGradient (myGradient, start, end, 0);
}
&lt;/pre&gt;

&lt;h3&gt;Creating a MonoTouch.Dialog Element&lt;/h3&gt;


	&lt;p&gt;If you are like me, lazy, you would likely not be writing a
	lot of GetCell methods and large dispatch tables for your
	UITableViews, and instead you are
	using &lt;a href="https://github.com/migueldeicaza/MonoTouch.Dialog"&gt;MonoTouch.Dialog&lt;/a&gt;.

	&lt;p&gt;MonoTouch.Dialog is an API that takes away the
	administrivia out of building UITableViews and lets you focus
	on the content.
	I &lt;a href="http://tirania.org/blog/archive/2010/Feb-23.html"&gt;discussed
	MonoTouch.Dialog last year&lt;/a&gt; on my old blog.

	&lt;p&gt;Once you have your own UITableViewCell, it is trivial to
	turn that into a MonoTouch.Dialog Element.  You would do it
	like this:

&lt;pre class="code-csharp"&gt;
public class MyDataElement : Element {
	static NSString key = new NSString ("myDataElement");
	public MyData MyData;

	public MyDataElement (MyData myData) : base (null)
	{
		MyData = myData;
	}

	public override UITableViewCell GetCell (UITableView tv)
	{
		var cell = tv.DequeueReusableCell (key) as MyDataCell;
		if (cell == null)
			cell = new MyDataCell (MyData, key);
		else
			cell.UpdateCell (MyData);
		return cell;
	}
}
&lt;/pre&gt;

	&lt;p&gt;With the code above, you have everything you need to make
	your custom cell to be used with MonoTouch.Dialog.

	&lt;p&gt;You can see the entire pattern in action
	in &lt;a href="https://github.com/migueldeicaza/TweetStation/blob/master/TweetStation/UI/TweetCell.cs"&gt;TweetStation's
	source code&lt;/a&gt;.   The 300 or so lines of code in that file
	are responsible for rendering a tweet in TweetStation.
	

</description>
      <link>http://tirania.org/monomac/archive/2011/Jan-18.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Jan-18.html</guid>
      <pubDate>Tue, 18 Jan 2011 19:32:00 -0500</pubDate>
    </item>
    <item>
      <title>Mono Packager and the Apple AppStore</title>
      <description>
	&lt;p&gt;We are happy to announce
	the &lt;a href="http://www.mono-project.com/MonoMacPackager"&gt;Mono
	Packager for OSX&lt;/a&gt;.   

	&lt;center&gt;
	&lt;img src="http://mono-project.com/files/2/2a/Md-monomac-bundle.png"&gt;
	&lt;br&gt;
	MonoDevelop UI for Mac Packages and Installers.
	&lt;/center&gt;

	&lt;p&gt;The Mono Packager for OSX makes it possible to create
	self-contained Mono applications that will run on OSX without
	requiring the Mono.framework to be previously installed on the
	system.  In combination with
	the &lt;a href="http://www.mono-project.com/MonoMac"&gt;MonoMac
	project&lt;/a&gt; you can build fully native MacOS X applications
	using your favorite .NET technologies.   From your choice of
	Mono/.NET languages, to your choice of Mono/.NET library. 

	&lt;p&gt;The packager can create both signed applications for
	distribution on the Mac AppStore, as well as creating
	installers for your software.

&lt;h3&gt;Mono on the Mac: Some Background&lt;/h3&gt;

	&lt;p&gt;Mono on OSX has historically been distributed as an image
	that installed itself in /Library/Frameworks/Mono.framework.
	Once Mono was installed, users could write code in 
	C# or their favorite .NET/Mono language and run the resulting
	executable.

	&lt;p&gt;The problem is that Mono.framework contains an entire
	development stack: compilers, GUI tools, command line tools,
	libraries, documentation which is convenient for developers,
	but most of the time, not very useful for end-users.

	&lt;p&gt;This meant that developers would typically ask users to
	first install the Mono.framework (a big download) and then
	they could install their applications.    

	&lt;p&gt;To work around that problem, some developers have chosen to
	manually embed Mono in their applications.  This has always
	been possible, but it was error-prone as developers would have
	to manually assemble Mono into their application bundle,
	configure Mono properly, and initialize the Mono runtime
	themselves.   Doable, but not pleasant. 

	&lt;p&gt;With today's release, we have taken the burden of creating
	self-contained Mono applications out of developer's hands and
	added it as a standard feature for developers to use.

&lt;h3&gt;The Mac AppStore&lt;/h3&gt;

	&lt;p&gt;The Mac AppStore requires that applications submitted to it
	are completely self-contained and they do not depend on
	third-party frameworks to be installed on the system.   It
	also requires that your application and installer be signed.

	&lt;p&gt;Both of those features are supported in our MonoMac
	Packager.   Developers can now create Mac AppStore ready
	applications using MonoDevelop and MonoMac.   We have
	integrated the package creation, installer creation, and
	signing processes into our MonoDevelop IDE.

	&lt;p&gt;All that developers have to do is sign up for Apple's
	Mac developer program, get their distribution certificates,
	build a fabulous application and upload the application using
	the Application Loader to Apple.com.

&lt;h3&gt;Upcoming: Linking&lt;/h3&gt;

	&lt;p&gt;In this version of the Mac bundler, we include all of the
	dependencies that your program takes.   For example, if you use
	the System.Xml library, the entire System.Xml library will be
	bundled with the application.

	&lt;p&gt;In our next release, we will add support
	for &lt;a href="http://www.mono-project.com/Linker"&gt;Mono's
	linker&lt;/a&gt;, the same technology we used
	in &lt;a href="http://monotouch.net"&gt;MonoTouch&lt;/a&gt; to reduce the
	executable size.

	&lt;p&gt;When you choose to use use the linker, the granularity of
	distribute changes from the library-level to the type level.
	For example, if you only use one type from System.Xml, the
	linker will strip out all of the unused classes and generate a
	new System.Xml library that only contains the one type that
	you used.

	&lt;p&gt;We did not want to wait for the linker to be ready before
	shipping our packager, but we should have it ready soon.
	
&lt;h3&gt;MonoMac Refresh&lt;/h3&gt;

	&lt;p&gt;As part of this release we have also issued a refresh to
	the MonoMac library and templates.

	&lt;p&gt;From now on, MonoMac binaries will default to be 4.0
	profile, allowing users to leverage all of the new features in
	the C# 4.0 language (like &lt;tt&gt;dynamic&lt;/tt&gt;) as well as the new
	.NET 4.0 APIs that we introduced with Mono 2.8.

	&lt;p&gt;The updates to the MonoMac API are described
	in &lt;a href="http://tirania.org/monomac/archive/2011/Jan-10-1.html"&gt;my
	other blog post&lt;/a&gt;.

</description>
      <link>http://tirania.org/monomac/archive/2011/Jan-10.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Jan-10.html</guid>
      <pubDate>Mon, 10 Jan 2011 17:23:00 -0500</pubDate>
    </item>
    <item>
      <title>New MonoMac Refresh!</title>
      <description>
	&lt;p&gt;As part of today's release of
	the &lt;a href="http://tirania.org/monomac/archive/2011/Jan-10.html"&gt;Mono
	Packager for OSX&lt;/a&gt; we have issued a new MonoMac refresh.

	&lt;p&gt;As we create more sample code, and start to write real
	applications with MonoMac, we have updated the API to be
	simpler, cleaner and more comprehensive.   This release is all
	about small incremental improvements to the MonoMac API.

	&lt;p&gt;As usual, we have updated the
	our &lt;a href="http://mono.ximian.com/monomac-docs/"&gt;MonoMac API documentation
	MonoMac API documentation&lt;/a&gt;.   If you are thinking about
	getting started with MonoMac, we strongly recommend you read
	our &lt;a href="http://www.mono-project.com/MonoMac"&gt;MonoMac&lt;/a&gt;
	page for some useful links and tutorials.

&lt;h3&gt;Statistics&lt;/h3&gt;

	&lt;p&gt;MonoMac 0.4 was installed by 263 developers, MonoMac 0.5 by
	369 developers.   Interesting considering that the holidays
	are a slow season:

	&lt;center&gt;
	&lt;img src="http://tirania.org/shots/1101091106IHKGeOBC.png"&gt;
	&lt;/center&gt;

&lt;h3&gt;Apps!&lt;/h3&gt;

	&lt;p&gt;&lt;a href="http://twitter.com/#!/praeclarum"&gt;Frank
	Krueger&lt;/a&gt; the creator
	of &lt;a href="http://icircuitapp.com/"&gt;iCircuit&lt;/a&gt; a real-time
	circuit emulator and editor for the iPad/iPhone has started a
	port of iCircuit to MacOS X using MonoMac:

	&lt;center&gt;
	&lt;img src="http://tirania.org/shots/1101091942LfvK58IN.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;Pretty amazing, considering that Frank only learned to use
	MonoMac yesterday (although he does have extensive MonoTouch
	experience).    &lt;b&gt;Update:&lt;/b&gt; He posted
	and &lt;a href="http://yfrog.com/h8mx8p"&gt;updated screenshot&lt;/a&gt;
	"now in technicolor".
	
&lt;h3&gt;MacDoc Sample&lt;/h3&gt;

	&lt;p&gt;During the holidays,
	I &lt;a href="https://github.com/mono/monomac/tree/master/samples/macdoc"&gt;wrote
	MacDoc&lt;/a&gt; a native front-end for the
	&lt;a href="http://www.mono-project.com/Monodoc"&gt;MonoDoc
	documentation engine&lt;/a&gt;.   I also took Jonathan Pobst's
	&lt;a href="https://github.com/jpobst/Kipunji"&gt;fabulous style
	sheets from Kipunji&lt;/a&gt; to spice up the UI a little bit.

	&lt;p&gt;This is the result:

	&lt;center&gt;
	&lt;img src="http://tirania.org/images/monomac-macdoc.png"&gt;
	&lt;/center&gt;

	&lt;p&gt;I still have to integrate the index and search features of
	MonoDoc into the UI, and I am struggling as to how to
	surface them in the UI.

	&lt;p&gt;The Index is supposed to have an alphabetical listing of
	classes, method, properties, fields, similar to the index at
	the end of a book.   I always found this to be very useful
	when developing with .NET.     The search functionality on the
	other hand uses Lucene to search in the documentation body.

	&lt;p&gt;At this point, I believe that I should add a tabbed
	widgets, and let the user pick between the tree view on the
	left and the index (with a new text-entry to do the
	incremental search).   But if the users uses the search on the
	toolbar, I should replace the tree and the index with a list
	of results.

	&lt;p&gt;Does the above make sense, or you think it is a terrible UI
	idea and completely unacceptable for OSX users?

	&lt;p&gt;I thought about merging the index and the body search, but
	it would render the index search a bit useless.   Anyways, if
	you are a Mac expert, please send feedback my way.
</description>
      <link>http://tirania.org/monomac/archive/2011/Jan-10-1.html</link>
      <author>miguel@xamarin.com (Miguel de Icaza)</author>
      <guid isPermaLink="true">http://tirania.org/monomac/archive/2011/Jan-10-1.html</guid>
      <pubDate>Mon, 10 Jan 2011 16:01:00 -0500</pubDate>
    </item>
  </channel>
</rss>