0

can someone help me, this message alert me all the time. its do to list apps the you add in one page note and it show on the second. here is my app:

//  FirstViewController.swift
import UIKit

class FirstViewController: UIViewController, UITableViewDataSource{

    @IBOutlet var myTableView: UITableView!

    func tableView(UITableView:tableView, commitEditingStyle editingStyle:UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
    {
        if editingStyle == UITableViewCellEditingStyle.delete
        {
            myItemList.removeAtIndex(indexPath.length.row)
              myTableView.reloadData()
        }
    }


    @available(iOS 2.0, *)
    internal func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
    {
    return myItemList.count
    }

    @available(iOS 2.0, *)
    internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    {
        let myCell = UITableViewCell(style: UITableViewCellStyle.Default,reuseIdentifier: "myCell")
        myCell.textLabel?.text = myItemList[indexPath.row]
        return myCell
    }
    override func viewDidAppeeard(animated:boll){
      //  print("viewDidAppeeard")
        myTableView.reloadData()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
            print("viewDidLoad")
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}



//  SecondViewController.swift
//  todolist
//  Created by אייל זיידמן on 16.9.2016.
//  Copyright © 2016 אייל זיידמן. All rights reserved.

import UIKit

class SecondViewController: UIViewController {
    var myItemList = [String]()

    @IBOutlet var myItemText: UITextField!
    @IBAction func addItem(sender: AnyObject) {
        if  (myItemText.text?.characters.count)! > 0
        {
            myItemList.append(myItemText.text!)
            myItemText.text = ""
            self.view.endEditing(true)
            print(myItemList)
        }

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
vadian
  • 274,689
  • 30
  • 353
  • 361
Chen
  • 35
  • 5
  • `myItemList` is visible only in `SecondViewController`. You need to pass the data via a segue. – vadian Sep 25 '16 at 07:22
  • how can i do it? @vadian – Chen Sep 25 '16 at 07:24
  • 1
    There are hundreds related topics here on SO for example [passing data between view controllers](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers?rq=1) – vadian Sep 25 '16 at 07:27

0 Answers0