ios - Web Service Apps in JSON with UITableView using Swift Language -


i new ios , learning web services. came across tutorial http://www.thedarkdev.com/webservice-swift-ios8-json-uitableview.html. tried program given getting these errors:

1.'objectforkeyedsubscript' unavailable: use subscripting @ line

let text: nsmutablestring = tmpdict.objectforkeyedsubscript(thetitle) as! nsmutablestring let detail: nsmutablestring = tmpdict.objectforkeyedsubscript(thedate) as! nsmutablestring 

2. extra argument 'error' in call @ line

var jsonsource: nsdata =  nsurlconnection.sendsynchronousrequest(urlrequest, returningresponse: response , error: err) 

3. use of unresolved identifier 'jsonobjects' @ line

for datadict : anyobject in jsonobjects 

viewcontroller.swift

import uikit import foundation  class viewcontroller: uiviewcontroller,nsurlconnectiondelegate, uitableviewdelegate {    @iboutlet var tabledata: uitableview!  let thetitle: nsstring = "title" let thedate: nsstring = "date" let day_thai: nsstring = "day_thai" let err: nserror? = nil let dictionary:nsdictionary? = nil let myobject: nsmutablearray = []  override func viewdidload() {     super.viewdidload()     var urlpath = "http://www.linezeed.com/calendar.php?api_key=p24567739e33xcbnfg0"     var jsonurl: nsurl = nsurl(string: urlpath)!     var urlrequest: nsurlrequest = nsurlrequest(url: jsonurl)     var response: autoreleasingunsafemutablepointer<nsurlresponse?>=nil     var jsonsource: nsdata =  nsurlconnection.sendsynchronousrequest(urlrequest, returningresponse: response , error: err)    //let jsonobjects = nsjsonserialization.jsonobjectwithdata(jsonsource, options: nsjsonreadingoptions.mutablecontainers, error: nil) nsmutablearray      {         if let jsonobjects = try nsjsonserialization.jsonobjectwithdata(jsonsource, options: nsjsonreadingoptions.mutablecontainers) as? nsmutablearray {             print(jsonobjects)         }     } catch let error nserror {         print(error.localizeddescription)     }       var datadict: nsdictionary     datadict : anyobject in jsonobjects {         var title_data: nsstring = datadict.objectforkey("title") nsstring         var date_data: nsstring = datadict.objectforkey("date") nsstring         println("วันหยุดคือ:"+title_data+" ตรงกับวันที่:"+date_data+"")          let dictionary = [thetitle: title_data, thedate: date_data]         myobject.addobject(dictionary)       }     print(myobject.count)     self.tabledata.registerclass(uitableviewcell.self, forcellreuseidentifier: "cell") }  //table func tableview(tableview: uitableview!, numberofrowsinsection section: int) -> int{      return myobject.count } func tableview(tableview: uitableview!, cellforrowatindexpath indexpath: nsindexpath!) -> uitableviewcell{      let tablecell: uitableviewcell = uitableviewcell(style: uitableviewcellstyle.subtitle, reuseidentifier: "cell")      var tmpdict: nsdictionary = myobject[indexpath.row] as! nsdictionary     let text: nsmutablestring = tmpdict.objectforkeyedsubscript(thetitle) as! nsmutablestring     let detail: nsmutablestring = tmpdict.objectforkeyedsubscript(thedate) as! nsmutablestring     tablecell.textlabel?.text=text string     tablecell.detailtextlabel?.text = detail string      return tablecell }  override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. } } 

can please me ?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -