在iOS简单通讯录的教程中,从登录界面到通讯录联系人界面的数据顺传部分的方法如下,根据不同的登录用户名,变换通讯录联系人界面的标题:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
UIViewController *vc = segue.destinationViewController;
vc.title = [NSString stringWithFormat:@"%@的联系人列表",_accountField.text];
}
我的理解是:这个方法新建了一个UIViewController
类的对象vc
,并把segue
的destinationViewController
赋值给了vc
,然后改变了vc
对象的title
,最后也没有返回vc
,和destinationViewController
的title
应该没有关系啊?为什么这样写是正确的呢?
这个方法新建了一个UIViewController类的对象vc
这里哪有新建VC的操作啊,没有任何内存分配啊。
这代码就和下面的是完全一样的
自然不需要返回。