title: parsing wordpress into IOS app
body: <p>I have <strong>UIImage View (post image), label(post title), UIWebView(post content)</strong>,
  and I have this code to parse wordpress JSON posts to my app </p>
  
  <pre><code> func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
  
      var maindata = (data[indexPath.row] as! NSDictionary)
  
        theTitle =  (maindata["post_title"] as? String)!
      theImg =  (maindata["image"] as? String)!
      theDate =  (maindata["post_date_gmt"] as? String)!
      theBody = (maindata["post_content"] as? String)!
  }
  </code></pre>
  
  <p>and I have installed JSON Api plugin on my wordpress, </p>
  
  <p>but I don't know how to parse to my app ??</p>
  
  <p>this is my whole code </p>
  
  <pre><code>import UIKit
  import Haneke
  
  
  var theTitle = ""
  var theImg = ""
  var theDate = ""
  var theBody = ""
  
  
  class ViewController: UIViewController , UITableViewDataSource , UITableViewDelegate {
  
  @IBOutlet var myTable: UITableView!
  
      // to refresh with pull down
  
      var ref:UIRefreshControl?
  
      // to refresh with pull down
  
  
  
  
      var data = []
  
  
      var prog:MBProgressHUD!
  
  
  
  
      override func viewDidLoad()
  
      {
          super.viewDidLoad()
  
          // to refresh with pull down
          self.ref = UIRefreshControl()
          self.ref?.attributedTitle = NSAttributedString(string: "اسحب للأسفل للتحديث")
          self.ref?.addTarget(self, action: "ref:", forControlEvents: UIControlEvents.ValueChanged)
          // to refresh with pull down
  
          myTable.addSubview(self.ref!)
  
  
  
  
  
  
  
  
          var heloWorldTimer = NSTimer.scheduledTimerWithTimeInterval(0.0001, target: self, selector: Selector("sayHello"), userInfo: nil, repeats: false)
  
          myTable.backgroundColor = UIColor.clearColor()
          myTable.dataSource = self
          myTable.delegate = self
  
  
  
  
  
      }
  // to refresh with pull down
      func ref (sender:UIRefreshControl)
      {
          self.myTable.reloadData()
          self.ref?.endRefreshing()
      }
      // to refresh with pull down
  
  
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
  
  
          func dataJsonFromURL(url:String)-&gt;NSArray
          {
  
              if var data = NSData(contentsOfURL: NSURL(string: url)!) {
  
              return (NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) as! NSArray)
          }
              else {
                  return data
  
          }
  
  
          }
      }
  
  
      func dataJsonFromURL(url:String)-&gt;NSArray
      {
          var data = NSData(contentsOfURL: NSURL(string: url)!)
          return (NSJSONSerialization.JSONObjectWithData(data!, options: nil, error: nil) as! NSArray)
      }
  
  
      func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
          if data.count == 0 {
              prog = MBProgressHUD.showHUDAddedTo(self.view, animated: true)
  
              prog.labelText = "جاري تحميل البيانات"
              prog.detailsLabelText = "الرجاء الإنتظار"
              return 0
          }
          else
          { MBProgressHUD.hideAllHUDsForView(self.view, animated: true)
              return data.count
          }
      }
  
  
  
      func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell
      {
          let cell = myTable.dequeueReusableCellWithIdentifier("NCell", forIndexPath: indexPath) as!
          newsCell
  
  
          var maindata = (data[indexPath.row] as! NSDictionary)
  
          cell.selectionStyle = UITableViewCellSelectionStyle.None
  
  
          cell.titleNews!.text = maindata["post_title"] as? String
          cell.dateNews!.text = maindata["post_date_gmt"] as? String
  
         if var urlImg = NSURL(string: (maindata["image"] as? String)!)
          {
            cell.imgNews.hnk_setImageFromURL(urlImg, placeholder: nil, format:nil, failure:nil, success:nil)
  
         }
  
  
          cell.backgroundColor = UIColor.clearColor()
  
          return cell
  
      }
  
  
      @IBAction func rfreshB(sender: UIBarButtonItem) {
  
          prog = MBProgressHUD.showHUDAddedTo(view, animated: true)
  
                  prog.labelText = "جاري تحميل البيانات"
                  prog.detailsLabelText = "الرجاء الإنتظار"
          //data = dataJsonFromURL("http://hhz20.co/newstest/PhpFile/admin/show.php")
          data = dataJsonFromURL("http://hhz20.co/testing/PhpFile/admin/show.php")
          myTable.reloadData()
      }
  
  
      func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
  
          var maindata = (data[indexPath.row] as! NSDictionary)
  
            theTitle =  (maindata["post_title"] as? String)!
          theImg =  (maindata["image"] as? String)!
          theDate =  (maindata["post_date_gmt"] as? String)!
          theBody = (maindata["post_content"] as? String)!
      }
  
      func sayHello ()
      {
          data = dataJsonFromURL("http://hhz20.co/testing/PhpFile/admin/show.php")
          myTable.reloadData()
  
  
      }
  
  
  
  }
  </code></pre>