2012-10-12 42 views
0

我分類了兩個視圖控制器。將數據從一個視圖控制器傳遞到另一個視圖控制器

第一個應該傳遞數據,NSUrl對象到第二個。

.M第一位的:

NSURL *temp = [NSURL URLWithString:@"http://example.com"]; 

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

presentationsFullScreen_ViewController.urlToUse = temp; 

第二個的.H:

#import <UIKit/UIKit.h> 

@interface PresentationsFullScreen_ViewController : UIViewController { 


    NSURL *urlToUse; 


} 



@property (nonatomic,retain) NSURL *urlToUse; 

這顯然是沒有工作,沒有編制,告訴我基本上是我沒有小類它並且在UIViewController上找不到屬性urlToUse。

如何正確地繼承子類?

謝謝!

+0

您是否將故事板中的目標視圖控制器的類設置爲您的自定義子類? – geraldWilliam

回答

1

這是正確的代碼

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

謝謝!!!是的,這有助於很多。謝謝!現在如此明顯。是的,我忘了導入我的.h – stackOverFlew

+0

我接受這個答案感謝大家的幫助,但沒有更多的答案需要! – stackOverFlew

+1

你剛剛投票,沒有被接受 – NeverBe

0

解決方案:

不要忘記導入.H:

#import "PresentationsFullScreen_ViewController" 

和不實例化的UIViewController而是與對象子類名稱:

PresentationsFullScreen_ViewController *presentationsFullScreen_ViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PresentationsFullScreen_ViewController"]; 
相關問題