xcode - Parse stack to second view -
im creating rpn calculator in swift. need code view calculations when tape button pressed segue secondvc. when tape button pressed display calculations entered.the functionality in second view controller. im knew programming. have implemented prepareforsegue in first vc. not know how pass stack numberofrowsinsection
calculator engine
class calculatorengine :nsobject { var operandstack = array<double>() func updatestackwithvalue(value: double) { self.operandstack.append(value) } func operate(operation: string) ->double { switch operation { case "×": if operandstack.count >= 2 { return self.operandstack.removelast() * self.operandstack.removelast() second view
class secondvcviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource { var array = [""] func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { return array.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = tableview.dequeuereusablecellwithidentifier("cell") uitableviewcell cell.textlabel?.text = array[indexpath.row] return cell
Comments
Post a Comment