0

I need to use the order array in another class (AddOrderVievContoller.swift class)

class OrderListViewController: UITableViewController {

    var orders: [Order] = []

error message in AddOrderVievContoller.swift class: use of unresolved indentifier 'orders'

if results != nil {
    orders = results as! [Order]
}
2
  • well, get hold of of an instance of the OrderListViewController inside your AddOrderVievContoller to get its orders value. Commented Nov 24, 2015 at 17:37
  • How are they related? You should have some callback if the view controller is requesting data from something else and particularly if the response is asynchronous Commented Nov 24, 2015 at 17:37

1 Answer 1

2

Create a global variable:

public var orders = [String]()

place this in-between the modules your importing (import UIKit) and the class definition:

import UIKit

public var orders = [String]()

class OrderListViewController: UITableViewController {


//viewDidLoad, etc. 
}

Then you can access the orders array in different viewControllers as you're currently trying to do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.