ios - How to segue from a Table Cell View in Swift -


this code have far on main table view view controller don't know how go transitioning new view controller selected cell display more content whatever cell selected.

import uikit  class mainvc: uitableviewcontroller, uitableviewdelegate, uitableviewdatasource {  @iboutlet var table1: uitableview! var postarray: [[string]] = []  var postsubject = "" var postdescription = "" var postdate = ""  override func viewdidload() {     super.viewdidload()     fetchdata() }  func fetchdata() {     println("success1")     postarray = []      let httpmethod = "get"      let timeout = 15      let urlasstring = "http://cgi.soic.indiana.edu/~team12/main_requests.php"     let url = nsurl(string: urlasstring)!      let urlrequest = nsmutableurlrequest(url: url,         cachepolicy: .reloadignoringlocalandremotecachedata,         timeoutinterval: 15.0)      urlrequest.httpmethod = httpmethod      let queue = nsoperationqueue()     println("success2")      nsurlconnection.sendasynchronousrequest(urlrequest,         queue: queue,         completionhandler: {(response: nsurlresponse!,             data: nsdata!,             error: nserror!) in              if data.length > 0 && error == nil{                 let html = nsstring(data: data, encoding: nsutf8stringencoding)              } else if data.length == 0 && error == nil{                 println("nothing downloaded")             } else if error != nil{                 println("error happened = \(error)")             }              if data.length > 0 && error == nil {                 let html = nsstring(data: data, encoding: nsutf8stringencoding)                  var newarrayofdicts : nsmutablearray = nsmutablearray()                 var arrayofdicts : nsmutablearray? = nsjsonserialization.jsonobjectwithdata(data, options:nsjsonreadingoptions.mutablecontainers, error:nil) as? nsmutablearray                 println("successmutable")                  if arrayofdicts != nil {                     item in arrayofdicts! {                          if var dict  = item as? nsmutabledictionary{                              if  dict["subject"] != nil{                                 self.postsubject = dict["subject"] string                                 self.postdescription = dict["subject"] string                                 self.postdate = dict["date"] string                             self.postarray.append([self.postsubject,self.postdescription,self.postdate])                                 println("successpost")                              }                         }                     }                 }             }         }     )     sleep(1) }   override func viewdidappear(animated: bool) {     super.viewdidappear(animated)     fetchdata()     tableview.reloaddata()     println("successanime")  }  override func didreceivememorywarning() {     super.didreceivememorywarning() }  override func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int {     return postarray.count }  override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell {     println("successoverride")      let cell = tableview.dequeuereusablecellwithidentifier("updatecell", forindexpath: indexpath)         uitableviewcell     println("successupdatecell")      cell.textlabel.text = postarray[indexpath.row][1]      cell.detailtextlabel?.text = postarray[indexpath.row][2]      println("success3")     return cell } 

try method

func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { ... } 

or can straight in storyboard ctrl dragging prototype cell next viewcontroller.

hope helps!!

edit

if want segue next view controller programmatically, can either:

performseguewithidentifier("yourseguename", sender: nil) 

or:

presentviewcontroller(nextviewcontroller, animated: true, completion: nil) 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -