我想知道哪些是在viewControllers之間發送參數的最佳方式。我知道有兩種可能性,在init調用之後傳遞公共屬性中的參數。自定義初始化或公共屬性什麼是viewControllers之間發送參數的最佳方式
ViewController *vc = [ViewController alloc] init];
vc.propertyOne = @"whatever";
vc.propertyTwo = @"whatever2";
或創建新的自定義的init像
initWithProperty:(NSString *)prperty1 andPropertyTwo:(NSString *)property2
{
self = [super init];
if (self) {
self.propertyOne = prperty1;
self.propertyTwo = property2;
}
return self;
}
ViewController *vc = [[ViewController alloc] initWithProperty:@"whatever andPropertyTwo:@"xxxx"];
我想知道每個人的優點和缺點,「何時」和「爲什麼」是更好地利用其中的一個。
[視圖控制器之間傳遞數據]的可能的重複(http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – RaffAl