﻿using System;
using RealWorldRx.Objects.ViewModels;
using UIKit;

namespace RealWorldRx.iOS
{
	public class BaseTableViewController<TViewModel> : UITableViewController where TViewModel : BaseViewModel
	{
		protected TViewModel viewModel;

		public BaseTableViewController(IntPtr handle) : base(handle)
		{
		}

		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			//TODO: Manage this with lifecycle events
			var appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate;
			viewModel = (TViewModel)Activator.CreateInstance(typeof(TViewModel), appDelegate.Environment);
		}
	}
}
