Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func jsonParsing()
- {
- let url2 = NSURL(string: "http://localhost:8000/straightred/jsonfixture")
- let data = NSData(contentsOfURL: url2!)
- var arr = NSJSONSerialization.JSONObjectWithData(data!, options: nil, error: nil) as NSArray
- for var i = 0 ; i < (arr as NSArray).count ; i++
- {
- arrDict.addObject((arr as NSArray) .objectAtIndex(i))
- }
- println(arrDict);
- }
- (
- {
- fields = {
- "away_team" = Burnley;
- awayteamscore = 2;
- fixturedate = "2014-11-22T15:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Stoke;
- hometeamscore = 1;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136932;
- },
- {
- fields = {
- "away_team" = Swans;
- awayteamscore = 1;
- fixturedate = "2014-11-22T15:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = ManCity;
- hometeamscore = 2;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136930;
- },
- {
- fields = {
- "away_team" = Sunderland;
- awayteamscore = 0;
- fixturedate = "2014-11-22T15:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Foxes;
- hometeamscore = 0;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 137852;
- },
- {
- fields = {
- "away_team" = "West Ham";
- awayteamscore = 1;
- fixturedate = "2014-11-22T15:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Everton;
- hometeamscore = 2;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136929;
- },
- {
- fields = {
- "away_team" = "West Bromwich";
- awayteamscore = 0;
- fixturedate = "2014-11-22T15:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Chelsea;
- hometeamscore = 2;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136928;
- },
- {
- fields = {
- "away_team" = QPR;
- awayteamscore = 0;
- fixturedate = "2014-11-22T15:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Newcastle;
- hometeamscore = 1;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136931;
- },
- {
- fields = {
- "away_team" = ManU;
- awayteamscore = 2;
- fixturedate = "2014-11-22T17:30:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Arsenal;
- hometeamscore = 1;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136927;
- },
- {
- fields = {
- "away_team" = Liverpool;
- awayteamscore = 1;
- fixturedate = "2014-11-23T13:30:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Crystal;
- hometeamscore = 3;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136926;
- },
- {
- fields = {
- "away_team" = Spurs;
- awayteamscore = 2;
- fixturedate = "2014-11-23T16:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = Hull;
- hometeamscore = 1;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136925;
- },
- {
- fields = {
- "away_team" = Southampton;
- awayteamscore = 1;
- fixturedate = "2014-11-24T20:00:00";
- fixturematchday = 12;
- fixturestatus = FINISHED;
- "home_team" = "Aston Villa";
- hometeamscore = 1;
- soccerseason = 354;
- };
- model = "straightred.straightredfixture";
- pk = 136924;
- }
- )
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return arrDict.count
- }
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as TblCell
- var homeTeamName : NSString=arrDict[indexPath.row] .valueForKey("home_team") as NSString
- var awayTeamName : NSString=arrDict[indexPath.row] .valueForKey("away_team") as NSString
- cell.lblHomeTeam.text = homeTeamName
- cell.lblAwayTeam.text = awayTeamName
- return cell
- }
- fatal error: unexpectedly found nil while unwrapping an Optional value
- (lldb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement