var shopList : NSArray!
override func viewDidLoad() {
super.viewDidLoad()
let defaults = NSUserDefaults.standardUserDefaults()
uid = defaults.objectForKey("uid") as! String
token = defaults.objectForKey("token") as! String
List()
}
func List() {
let process = JSONNetwork()
var arr = ["manager" : "shop", "method" : "get_shop_all", "uid" : uid, "token": token, "page" : "0", "latitude" : "37.49521", "longitude" :"127.03318833333333"]
process.delegate = self
process.jsonProccess(arr, code: NetworkCode().GET_SHOP_ALL)
}
func returnJSON(data: NSDictionary, code: Int) {
if NetworkCode().GET_SHOP_ALL==code{
var returnData2 : NSDictionary = data.valueForKey("data") as! NSDictionary
println("ttt")
println(returnData2)
shopList = returnData2.valueForKey("shop_list") as? NSArray
NSOperationQueue.mainQueue().addOperationWithBlock {
self.tableView.reloadData()//테이블뷰 재로딩
}
}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
if (shopList == nil) {
return 0
} else {
return shopList.count
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell : MainTableViewCell = tableView.dequeueReusableCellWithIdentifier("MainTableViewCell") as! MainTableViewCell
println("asfdsaf")
var cellData : NSDictionary! = shopList[indexPath.row] as! NSDictionary
var mcode = cellData.valueForKey("mcode") as! String
var mname = cellData.valueForKey("mname") as! String
var shop_type = cellData.valueForKey("shop_type") as! Int
var address = cellData.valueForKey("address") as! String
var option_desc = cellData.valueForKey("option_desc") as! String
var reservation_count = cellData.valueForKey("reservation_count") as! Int
var favorities_count = cellData.valueForKey("favorities_count") as! Int
var main_image = cellData.valueForKey("main_image") as! String
var distance = cellData.valueForKey("distance") as! Int
// cell.proImage.image = UIImage(named: )
cell.adressLabel.text = address
cell.eventLabel.text = option_desc
cell.reserLabel.text = String(reservation_count)
cell.favLabel.text = String(favorities_count)
cell.testLabel.text = mname
return cell
}
'Programming > Swift' 카테고리의 다른 글
뒤로가기버튼 (0) | 2015.05.15 |
---|---|
객체 전달 (0) | 2015.05.13 |
unbalanced calls to begin/end appearance transitions for uiviewcontroller (0) | 2015.05.05 |
tableView 기본적으로 꼭 들어가야할 메소드. (0) | 2015.05.04 |
xib에서 스토리보드에 있는 뷰 이동 (0) | 2015.05.04 |