I have simple example:
- NavViewController
- ViewController
- ViewController2
In ViewController:
#import "ViewController.h"
#import "ViewController2.h"
@interface ViewController ()
@end
NSArray *array;// Neither in @interface nor in @implementation
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
array = [[NSArray alloc] initWithObjects:@"12345", nil];
ViewController2 *vc = [[ViewController2 alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
In ViewConroller2:
#import "ViewController2.h"
@interface ViewController2 ()
@end
NSArray *array;
@implementation ViewController2
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%@",array);
}
I don't understand why my array in viewController2 passed data from viewController? Can explain this?
Guys I know how pass data to another viewController with property. I want to understand why, in this case, the data is transferred!