Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. func jsonParsing()
  2. {
  3.  
  4.  
  5. let url2 = NSURL(string: "http://localhost:8000/straightred/jsonfixture")
  6.  
  7. let data = NSData(contentsOfURL: url2!)
  8.  
  9. var arr = NSJSONSerialization.JSONObjectWithData(data!, options: nil, error: nil) as NSArray
  10.  
  11. for var i = 0 ; i < (arr as NSArray).count ; i++
  12. {
  13. arrDict.addObject((arr as NSArray) .objectAtIndex(i))
  14. }
  15.  
  16. println(arrDict);
  17.  
  18. }
  19.  
  20. (
  21. {
  22. fields = {
  23. "away_team" = Burnley;
  24. awayteamscore = 2;
  25. fixturedate = "2014-11-22T15:00:00";
  26. fixturematchday = 12;
  27. fixturestatus = FINISHED;
  28. "home_team" = Stoke;
  29. hometeamscore = 1;
  30. soccerseason = 354;
  31. };
  32. model = "straightred.straightredfixture";
  33. pk = 136932;
  34. },
  35. {
  36. fields = {
  37. "away_team" = Swans;
  38. awayteamscore = 1;
  39. fixturedate = "2014-11-22T15:00:00";
  40. fixturematchday = 12;
  41. fixturestatus = FINISHED;
  42. "home_team" = ManCity;
  43. hometeamscore = 2;
  44. soccerseason = 354;
  45. };
  46. model = "straightred.straightredfixture";
  47. pk = 136930;
  48. },
  49. {
  50. fields = {
  51. "away_team" = Sunderland;
  52. awayteamscore = 0;
  53. fixturedate = "2014-11-22T15:00:00";
  54. fixturematchday = 12;
  55. fixturestatus = FINISHED;
  56. "home_team" = Foxes;
  57. hometeamscore = 0;
  58. soccerseason = 354;
  59. };
  60. model = "straightred.straightredfixture";
  61. pk = 137852;
  62. },
  63. {
  64. fields = {
  65. "away_team" = "West Ham";
  66. awayteamscore = 1;
  67. fixturedate = "2014-11-22T15:00:00";
  68. fixturematchday = 12;
  69. fixturestatus = FINISHED;
  70. "home_team" = Everton;
  71. hometeamscore = 2;
  72. soccerseason = 354;
  73. };
  74. model = "straightred.straightredfixture";
  75. pk = 136929;
  76. },
  77. {
  78. fields = {
  79. "away_team" = "West Bromwich";
  80. awayteamscore = 0;
  81. fixturedate = "2014-11-22T15:00:00";
  82. fixturematchday = 12;
  83. fixturestatus = FINISHED;
  84. "home_team" = Chelsea;
  85. hometeamscore = 2;
  86. soccerseason = 354;
  87. };
  88. model = "straightred.straightredfixture";
  89. pk = 136928;
  90. },
  91. {
  92. fields = {
  93. "away_team" = QPR;
  94. awayteamscore = 0;
  95. fixturedate = "2014-11-22T15:00:00";
  96. fixturematchday = 12;
  97. fixturestatus = FINISHED;
  98. "home_team" = Newcastle;
  99. hometeamscore = 1;
  100. soccerseason = 354;
  101. };
  102. model = "straightred.straightredfixture";
  103. pk = 136931;
  104. },
  105. {
  106. fields = {
  107. "away_team" = ManU;
  108. awayteamscore = 2;
  109. fixturedate = "2014-11-22T17:30:00";
  110. fixturematchday = 12;
  111. fixturestatus = FINISHED;
  112. "home_team" = Arsenal;
  113. hometeamscore = 1;
  114. soccerseason = 354;
  115. };
  116. model = "straightred.straightredfixture";
  117. pk = 136927;
  118. },
  119. {
  120. fields = {
  121. "away_team" = Liverpool;
  122. awayteamscore = 1;
  123. fixturedate = "2014-11-23T13:30:00";
  124. fixturematchday = 12;
  125. fixturestatus = FINISHED;
  126. "home_team" = Crystal;
  127. hometeamscore = 3;
  128. soccerseason = 354;
  129. };
  130. model = "straightred.straightredfixture";
  131. pk = 136926;
  132. },
  133. {
  134. fields = {
  135. "away_team" = Spurs;
  136. awayteamscore = 2;
  137. fixturedate = "2014-11-23T16:00:00";
  138. fixturematchday = 12;
  139. fixturestatus = FINISHED;
  140. "home_team" = Hull;
  141. hometeamscore = 1;
  142. soccerseason = 354;
  143. };
  144. model = "straightred.straightredfixture";
  145. pk = 136925;
  146. },
  147. {
  148. fields = {
  149. "away_team" = Southampton;
  150. awayteamscore = 1;
  151. fixturedate = "2014-11-24T20:00:00";
  152. fixturematchday = 12;
  153. fixturestatus = FINISHED;
  154. "home_team" = "Aston Villa";
  155. hometeamscore = 1;
  156. soccerseason = 354;
  157. };
  158. model = "straightred.straightredfixture";
  159. pk = 136924;
  160. }
  161. )
  162.  
  163. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  164.  
  165. return arrDict.count
  166. }
  167.  
  168. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
  169.  
  170. var cell:TblCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as TblCell
  171.  
  172. var homeTeamName : NSString=arrDict[indexPath.row] .valueForKey("home_team") as NSString
  173.  
  174. var awayTeamName : NSString=arrDict[indexPath.row] .valueForKey("away_team") as NSString
  175.  
  176. cell.lblHomeTeam.text = homeTeamName
  177.  
  178. cell.lblAwayTeam.text = awayTeamName
  179.  
  180. return cell
  181.  
  182. }
  183.  
  184. fatal error: unexpectedly found nil while unwrapping an Optional value
  185. (lldb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement