swift - Definition conflicts with previous value - also, when is override deleted? -


so attempting make tableview out of array of cloudkit downloaded items. however, i'm having simple little "definition conflicts pervious value" error. error occurs cellforrowatindexpath function - supposedly conflicts numberofrowsinsection function. have attempted moving/deleting brackets of latter function , placing question mark/optional @ end... "-> uitableviewcell?" no avail. error coming from?

also, stands, xcode deleted override portion of each tableview function. why stay , when deleted?

import uikit import cloudkit class diningtable: uitableviewcontroller {  var categories: array<ckrecord> = [] override func viewdidload() {     super.viewdidload()  func getrecords()     {         categories = []          let publicdatabase = ckcontainer.defaultcontainer().publicclouddatabase         let predicate = nspredicate(value: true)         let query = ckquery(recordtype: "diningtypes", predicate: predicate)          let queryoperation = ckqueryoperation(query: query)         queryoperation.desiredkeys  = ["name", "address", "picture"]         queryoperation.qualityofservice = .userinteractive         queryoperation.recordfetchedblock = { (record:ckrecord) -> void in             let categoryrecord = record             self.categories.append(categoryrecord)     }         queryoperation.querycompletionblock = { (cursor:ckquerycursor?, error: nserror?) -> void in             if (error != nil) {                 print("failed data icloud - \(error!.localizeddescription)")                 dispatch_async(dispatch_get_main_queue(), {                     self.tableview.reloaddata()                 })             }         }         publicdatabase.addoperation(queryoperation     }  func tableview(tableview: uitableview, numberofrowsinsection: int) -> int {         return self.categories.count     }      func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell     {           let cell = tableview.dequeuereusablecellwithidentifier("dining") as! diningtablecell         let restaurant: ckrecord = categories[indexpath.row]         cell.restaurantname?.text = restaurant.valueforkey("name") as? string          let img = restaurant.objectforkey("picture") as! ckasset          cell.restaurantphoto.image = uiimage(contentsoffile: img.fileurl.path!)           return cell     } func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {     if segue.identifier == "segue1" {             if let destviewcontroller = segue.destinationviewcontroller as? restauranttable {             let indexpath = self.tableview.indexpathforselectedrow!             destviewcontroller.indexpath1 = indexpath           }     }     } func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. } } } 

are sure that's code or have accidentally removed lines?

because, stands, table view functions embedded in viewdidload function... need object level functions.

note indentation level of code when have xcode indent code (right-click on screen , select structure->re-indent.

import uikit import cloudkit  class diningtable: uitableviewcontroller {     var categories: array<ckrecord> = []     override func viewdidload() {         super.viewdidload()     } // <---  missing close brace here.      func getrecords()     {         categories = []          let publicdatabase = ckcontainer.defaultcontainer().publicclouddatabase          let predicate = nspredicate(value: true)         let query = ckquery(recordtype: "diningtypes", predicate: predicate)          let queryoperation = ckqueryoperation(query: query)         queryoperation.desiredkeys  = ["name", "address", "picture"]         queryoperation.qualityofservice = .userinteractive         queryoperation.recordfetchedblock = { (record:ckrecord) -> void in             let categoryrecord = record             self.categories.append(categoryrecord)         }         queryoperation.querycompletionblock = { (cursor:ckquerycursor?, error: nserror?) -> void in             if (error != nil) {                 print("failed data icloud - \(error!.localizeddescription)")                 dispatch_async(dispatch_get_main_queue(), {                     self.tableview.reloaddata()                 })             }         }         publicdatabase.addoperation(queryoperation)     }      override func tableview(tableview: uitableview, numberofrowsinsection: int) -> int {         return self.categories.count     }      override func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell     {         let cell = tableview.dequeuereusablecellwithidentifier("dining") as! diningtablecell         let restaurant: ckrecord = categories[indexpath.row]         cell.restaurantname?.text = restaurant.valueforkey("name") as? string           let img = restaurant.objectforkey("picture") as! ckasset          cell.restaurantphoto.image = uiimage(contentsoffile: img.fileurl.path!)           return cell     }      override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {         if segue.identifier == "segue1" {             if let destviewcontroller = segue.destinationviewcontroller as? restauranttable {                 let indexpath = self.tableview.indexpathforselectedrow!                 destviewcontroller.indexpath1 = indexpath             }         }     }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     } } 

Comments

Popular posts from this blog

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

wordpress - (T_ENDFOREACH) php error -

Using django-mptt to get only the categories that have items -