I’m trying to access an array from a custom UITableViewCell subclass. The array is created in my tableViewController. This is driving me crazy. I access other view controller’s objects all the time with ViewController *vcInstance. I actually need to edit the array from my cell subclass, but I can’t even NSLog it from my cell view controller. The array logs perfectly in my tableViewController. All I get is null from the cell subclass.
CustomCell.h
@property (retain, nonatomic) SongsViewController *vc;
CustomCell.m
@synthesize vc;
-(IBAction)setStateOfObjects
{
NSMutableArray *array = [[NSMutableArray alloc] initWithArray:vc.parseTrackArray];
NSLog(@"%@", array);
}
I’ve also simply tried: CustomCell.m
-(IBAction)setStateOfObjects
{
SongsViewController *vc;
NSLog(@"%@", vc.parseTrackArray);
}
EDIT: You’re not quite understanding how object referencing works. When you request an object from an array, or some other object that is “retaining” it, you are not creating a new object. So, you don’t end up with your “previous object” and an “updated object”. Consider this:
Considering that…
The way you’re going about this is backwards. Make a property in your UITableVieCell subclass for your array