Skip to content

Instantly share code, notes, and snippets.

@ybigus
Last active December 21, 2015 16:49
Show Gist options
  • Save ybigus/6336022 to your computer and use it in GitHub Desktop.
Save ybigus/6336022 to your computer and use it in GitHub Desktop.
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var list = new List<CategoryModel>();
var table = new UITableView (new RectangleF (0, 0, View.Bounds.Width, View.Bounds.Height));
View.Add (table);
try{
var request = WebRequest.Create("http://api.bbcnews.appengine.co.uk/topics");
var response = request.GetResponse ();
using(var stream = new StreamReader(response.GetResponseStream())){
var json = stream.ReadToEnd ();
var jsonVal = JsonValue.Parse (json);
for(var i=0; i<jsonVal["topics"].Count; i++){
list.Add (new CategoryModel () {
Id = jsonVal["topics"][i]["id"],
Title = jsonVal["topics"][i]["title"]
});
}
};
response.Close ();
}catch{
}
table.Source = new CategoryTableSource(list.ToArray(), NavigationController);
// Perform any additional setup after loading the view, typically from a nib.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment