Last active
December 21, 2015 16:49
-
-
Save ybigus/6336022 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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