uitableview - create a UITableViewController programmatically in Swift -


i'm trying to, title say, set uitableviewcontroller programmatically. after few hours of trying hope can me. and, yes, hve checked out other posts on matter:

import uikit  class mainviewcontroller: uitableviewcontroller {      init(style: uitableviewstyle) {         super.init(style: style)         // custom initialization     }      override func viewdidload() {         super.viewdidload()       }      override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }      // #pragma mark - table view data source      override func numberofsectionsintableview(tableview: uitableview?) -> int {         return 1     }      override func tableview(tableview: uitableview?, numberofrowsinsection section: int) -> int {         return 5     }       override func tableview(tableview: uitableview?, cellforrowatindexpath indexpath: nsindexpath?) -> uitableviewcell? {         var cell = tableview?.dequeuereusablecellwithidentifier("cell") as? uitableviewcell          if !cell {             cell = uitableviewcell(style: uitableviewcellstyle.value1, reuseidentifier: "cell")         }         cell!.textlabel.text = "test"         return cell     }  } 

and appdelegate looks this:

func application(application: uiapplication, didfinishlaunchingwithoptions launchoptions: nsdictionary?) -> bool {         self.window = uiwindow(frame: uiscreen.mainscreen().bounds)          let mainviewcontroller: uitableviewcontroller = mainviewcontroller(style: uitableviewstyle.plain)         let navigationcontroller: uinavigationcontroller = uinavigationcontroller()         navigationcontroller.pushviewcontroller(mainviewcontroller, animated: false)          self.window!.rootviewcontroller = navigationcontroller         self.window!.backgroundcolor = uicolor.whitecolor()         self.window!.makekeyandvisible()         return true     } 

the program run, does, following error:

fatal error: use of unimplemented initializer 'init(nibname:bundle:)' class 'helloworld.mainviewcontroller' 

i changes mainviewcontroller(style: uitableviewstyle.plain) mainviewcontroller(nibname: nil, bundle: nil) following syntax error: extra argument 'bundle' in call

any appreciated

i'm using subclass of uitableviewcontroller no issues, using (nibname:bundle:) form, i've overridden in subclass. tried replacing subclass standard uitableviewcontroller, , still worked fine. possibly overriding init(...) method in subclass?


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -