2011-09-15 46 views
0

的設置:iOS版 - 傳遞值從對象到它是一個包含

我有一個AppDelegate中,並在該聲明是CustomUIViewController.h並在控制器我已經RandomName.h宣佈(作爲一個對象,而不是一個子類)我可以使用[super methodName]或類似的從RandomName.h上的方法觸發CustomUIViewController上的方法嗎?

或者我必須將它傳遞給appDelegate然後從那裏傳遞給CustomUIViewController? (如何我已經做了)

感謝

附:咖啡很好。

+0

確切地在項目中我正在研究這是一個爲我播放圖像序列的類。我試圖找到的另一種方法是將RandomName的「我完成動畫」值傳遞迴CustomUIView,而無需通過AppDelegate運行。 – Mytheral

+0

對於任何查看此主題的人來說,通知中心都可以用於此目的。 – Mytheral

+0

鏈接解釋:http://stackoverflow.com/questions/2191594/how-to-send-and-receive-message-through-nsnotificationcenter-in-objective-c – Mytheral

回答

0

我想我已經理解了你的問題。請原諒我,如果我不;-)

super不工作的方式。你可以簡單地調用,

[appDelegate.customViewController methodName]; 

的另一種方法是將customViewController的引用傳遞到RandomName對象,像,

[[RandomName alloc] initWithParent:self]; 

你必須不斷的自我參考initWithParent方法,可以說變量名是,並調用這樣的方法,

[parent methodName]; 
+0

謝謝,這是更清潔,那麼我目前正在做的。 – Mytheral

+0

很高興我能幫到你! – EmptyStack

相關問題