data passing and using json data from alamofire with swift -
i integrated alamofire, got 1 problem use data within server communication.
before tell problem show code:
class viewcontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { @iboutlet weak var mainviewtable: uitableview! @iboutlet weak var sidesopen: uibarbuttonitem! @iboutlet weak var groupbutton: uibutton! var apps:[sample] = [sample]() override func viewdidload() { super.viewdidload() sidesopen.target = self.revealviewcontroller() sidesopen.action = selector("revealtoggle:") self.view.addgesturerecognizer(self.revealviewcontroller().pangesturerecognizer()) self.setupsample() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } func setupsample() { alamofire.request(.get, "http://{url}").responsejson{ (request, response, data, error) in var json = json(data!) var index = 0; index < json["store"].count; ++index{ var marketinfo = json["store"][index]["name"].stringvalue var imageurl = json["store"][index]["img"].stringvalue let sample_menu = sample(marketinfo: marketinfo, imagename: imageurl, button: "") self.apps.append(sample_menu) } } print(self.apps) } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return apps.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { print(setupsample()) let cell: tblcell = tableview.dequeuereusablecellwithidentifier("marketcell") as! tblcell let sample = apps[indexpath.row] cell.setcell(sample.marketinfo , imagename: sample.imagename, coupon: "s/t.jpeg") return cell } }
within setupsample function have got 1 problem have no idea passing or taking out json data. in function tried print result can have however, result empty.
Comments
Post a Comment