将数据从一个viewcontroller传递到另一个

我将两个视图控制器子类化。

第一个应该传递数据,NSUrl对象传递给第二个。

.m的第一个:

NSURL *temp = [NSURL URLWithString:@"http://example.com"]; UIViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"]; presentationsFullScreen_ViewController.urlToUse = temp; 

.h的第二个:

 #import  @interface PresentationsFullScreen_ViewController : UIViewController { NSURL *urlToUse; } @property (nonatomic,retain) NSURL *urlToUse; 

它显然不起作用而且没有编译,基本上告诉我,我没有将它子类化,并且在UIViewController上找不到属性urlToUse。

我如何正确子类?

谢谢!

这是正确的代码

  PresentationsFullScreen_ViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"]; presentationsFullScreen_ViewController.urlToUse = temp; 

解:

不要忘记导入.h:

 #import "PresentationsFullScreen_ViewController" 

并且不要使用UIViewController实例化对象,而是使用子类的名称实例化:

 PresentationsFullScreen_ViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"];