title: Swift Json count and create TableView
body: <p>I need to create a tableview and fill that with database information that I take with json. This is the response I get from the database with json</p>
  
  <pre><code> {
  "news": [
      {
          "id": "35",
          "type": "news",
          "title": "final test for offer",
          "city": "Mumbai",
          "description": "Test description",
          "image": "http://www.saimobileapp.com/mobileappbackend/news/IMG_0421.JPG"
      },
      {
          "id": "31",
          "type": "news",
          "title": "new test",
          "city": "Mumbai",
          "description": "yes its a test msg",
          "image": "http://www.saimobileapp.com/mobileappbackend/news/Chrysanthemum.jpg"
      },
      {
          "id": "30",
          "type": "news",
          "title": "This is a test news",
          "city": "Mumbai",
          "description": "Test description",
          "image": "http://www.saimobileapp.com/mobileappbackend/news/1.jpg"
      }
  ]
  }
  </code></pre>
  
  <p>These are 3 different news with title etc., so I need to count it as I will add new, and create a table view in base of that.</p>
  
  <p>This is my code now to get the database information with new EDIT:</p>
  
  <pre><code>    func LoadNews() {
  
  
      let post:NSString = ""
  
      NSLog("PostData: %@",post);
  
      let url:NSURL = NSURL(string: "http://saimobileapp.com/services/sai_news.php")!
  
      let postData:NSData = post.dataUsingEncoding(NSASCIIStringEncoding)!
  
      let postLength:NSString = String( postData.length )
  
      let request:NSMutableURLRequest = NSMutableURLRequest(URL: url)
      request.HTTPMethod = "POST"
      request.HTTPBody = postData
      request.setValue(postLength as String, forHTTPHeaderField: "Content-Length")
      request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
      request.setValue("application/json", forHTTPHeaderField: "Accept")
  
  
      var reponseError: NSError?
      var response: NSURLResponse?
  
      var urlData: NSData? = NSURLConnection.sendSynchronousRequest(request, returningResponse:&amp;response, error:&amp;reponseError)
  
      if ( urlData != nil ) {
          let res = response as! NSHTTPURLResponse!;
  
          NSLog("Response code: %ld", res.statusCode);
          if (res.statusCode &gt;= 200 &amp;&amp; res.statusCode &lt; 300)
          {
              let responseData:NSString  = NSString(data:urlData!, encoding:NSUTF8StringEncoding)!
  
              NSLog("Response ==&gt; %@", responseData);
  
              var error: NSError?
  
                           var Title: [String] = []
  
              if let jsonData = NSJSONSerialization.JSONObjectWithData(urlData!, options: nil, error: &amp;error) as? [String:AnyObject] { // dictionary
                  if let locationsArray = jsonData["news"] as? [[String:AnyObject]] { // array of dictionaries
                      for locationDictionary in locationsArray { // we loop in the array of dictionaries
                          if let location = locationDictionary["title"] as? String { // finally, access the dictionary like you were trying to do
  
                              Title.append(location)
  
                              var SaveTitle = save.setObject(Title, forKey: "NewsTitle")
  
                          }
                      }
                  }
              }
  
  
  
  
  
  
  
  
  
  
          }
  
  
  
  
      }
  
  
  }
  </code></pre>
  
  <p>And for TableView i use that now :</p>
  
  <pre><code>    // MARK:  UITextFieldDelegate Methods
  func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
      return 1
  }
  
  
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
     var FormName = save.arrayForKey("NewsTitle")!
  
      return FormName.count
  }
  
  
  
  
  
  
  
  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      var FormName = save.arrayForKey("NewsTitle")!
  
      var cell:UITableViewCell = self.TableView.dequeueReusableCellWithIdentifier("Cell") as! UITableViewCell
  
      let row = indexPath.row
  
      cell.textLabel?.text = FormName[indexPath.row] as! String
  
  
  
  
  
      if (indexPath.row % 2 == 0) {
          cell.backgroundColor = UIColor.clearColor()
      }else{
  
          cell.backgroundColor = UIColor.clearColor()
          cell.textLabel?.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.0)
      }
  
  
  
  
      cell.textLabel?.textColor = UIColor.whiteColor()
      return cell
  
  }
  // MARK:  UITableViewDelegate Methods
  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
      TableView.deselectRowAtIndexPath(indexPath, animated: false)
  
      let row = indexPath.row
  </code></pre>
  
  <p>How can i show the description in the second page when i tap on the cell?</p>
  
  <p>Can anyone please help me? Thanks in advance.</p>