Im trying to append to my array
var feedArray: [AnyObject] = []
from another class. I have 2 classes:
class FeedViewController: UIViewController, UICollectionViewDataSource,
UICollectionViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
var feedArray: [AnyObject] = []
and
class AddEditViewController: UIViewController, NSFetchedResultsControllerDelegate,
UIImagePickerControllerDelegate, UINavigationControllerDelegate {
I want to in my "AddEditViewController" append the array "feedArray". But I'm not able. I have tried:
FeedViewController().feedArray.append("TheObjectImTryingToAdd")
I even tried to put
print(FeedViewController().feedArray.count)
but the result is always 0 even though the array have 3 objects.
what I'm i doing wrong? if you want to see detailed code, this is my previous question: why won't my main viewcontroller update when i segue back?
FeedViewController()creates a new instance of the view controller. You have to access the view controller that is being presented instead of creating a new one.