将数据对象传递给另一个VC

时间:2015-10-05 15:22:56

标签: ios objective-c core-data instantiation

我正在实例化一个详细视图控制器,该控制器存在于故事板中,来自不同的详细视图控制器并希望为其提供数据对象。在起始视图控制器中,我使用一个对象(让我们称之为起始对象),该对象通过关系链接到第二个视图控制器所需的第二个数据对象。我的问题是如何为第二个视图控制器提供第二个数据对象?以下代码启动新VC但没有必要的数据:

SecondObject *secondobject;
detailVC *secondViewController =
         [self.storyboard instantiateViewControllerWithIdentifier:@"detail"];
         [self.navigationController pushViewController:secondViewController animated:YES];
         secondViewController.startingobject=_startingobject; 

         secondViewController.secondobject = secondobject;

2 个答案:

答案 0 :(得分:3)

首先,尝试在推送之前将数据传递到第二个VC 。这可能会解决您的问题。

答案 1 :(得分:1)

尝试:

secondViewController.startingobject = _startingobject;

trigger CustomerTigger on Customer__c(Before insert, Before update) {
    List < Customer__c > StaActiList = [Select ID, First_Name__c, Last_Name__c, Title__c, Address__c, Gender__c, RefAccount__c
    from Customer__c];
    for (Customer__c opp: Trigger.new) {
        for (Customer__c sa: StaActiList) {
            try {

                if (sa.First_Name__c == opp.First_Name__c && sa.Last_Name__c == opp.Last_Name__c && sa.Title__c == opp.Title__c) {
                    List < Id > lstId = new List < Id > ();
                    List < Customer__c > existoppList = [Select Id from Customer__c where Id = : sa.Id];
                    delete existoppList;
                }

            } catch (Exception Ex) {

            }
        }
    }
}

在推送新的viewcontroller之前使用此代码

相关问题