Skip to content

Instantly share code, notes, and snippets.

@Phyyl
Last active August 29, 2015 14:23
Show Gist options
  • Save Phyyl/e9e1aa96d7f7427b497c to your computer and use it in GitHub Desktop.
Save Phyyl/e9e1aa96d7f7427b497c to your computer and use it in GitHub Desktop.
public class ControllerDictionary<TKey, TValue, TCast> : Dictionary<TKey, TValue> where TValue : UIViewController where TCast : TValue
{
public new TValue this[TKey key]
{
get
{
if (ContainsKey(key))
{
return base[key] as TCast;
}
else
{
return default(TValue) as TCast;
}
}
set
{
if (ContainsKey)
{
base[key] = value;
}
else
{
Add(key, value);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment