I'm trying to pass an array of objects (IUButtons) from ViewController to SecondViewController. I can't figure out what piece I'm missing (edited for relevancy):
ViewController.h
ViewController.m
Note: At this point, the log shows myButtons has been properly loaded.
SecondViewController.h
SecondViewController.m
Note: Log shows this version of myButtons as (null).
I've tried myButtons = [[NSMutableArray alloc]init]; in SecondViewController.m right before the log, which returned ( ). I've also tried
Thanks in advance!
ViewController.h
Code:
#import SecondViewController.h
@interface ViewController : UIViewController{
NSMutableArray *myButtons;
}
@property (nonatomic, retain) NSMutableArray *myButtons;
ViewController.m
Code:
#import ViewController.h
#import SecondViewController.h
@synthesize myButtons;
...
- (void)addMyButton
{
//'for' loop with buttons created here
[myButtons addObject:button];
NSLog(@"Array contents: %@", myButtons);
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"toResults"])
{
SecondViewController *obj = [[SecondViewController alloc]init];
obj.myButtons = [[NSMutableArray alloc]initWithArray:self.myButtons];
}
}
Note: At this point, the log shows myButtons has been properly loaded.
SecondViewController.h
Code:
#import "ViewController.h"
@interface SecondViewController : UIViewController{
NSMutableArray *myButtons;
}
@property (nonatomic, retain) NSMutableArray *myButtons;
SecondViewController.m
Code:
#import "SecondViewController.h"
#import "ViewController.h"
@synthesize myButtons;
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Array contents: %@", myButtons);
...
}
Note: Log shows this version of myButtons as (null).
I've tried myButtons = [[NSMutableArray alloc]init]; in SecondViewController.m right before the log, which returned ( ). I've also tried
Code:
obj.myButtons = [[NSMutableArray alloc]init];
obj.myButtons = myButtons;
Thanks in advance!