更新时间:2023-12-05 17:37:52
我会这样做如下 -
I would do it as follows -
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"NextSegue"])
{
DestinationViewController *dest = [segue destinationViewController];
dest.myData = self.myData;
}
}
在DestinationViewController.h中,你应该创建一个property -
And in the DestinationViewController.h, you should create a property -
#import <UIKit/UIKit.h>
@interface DestinationViewController : UIViewController
@property (nonatomic, strong) NSObject *myData;
@end
此外,请确保合成在DestinationViewController.m的myData的属性 -
And also, make sure to synthesize the myData property in DestinationViewController.m -
@interface DestinationViewController ()
@end
@implementation DestinationViewController
@synthesize myData = _myData;
// other methods here
@end