-1
我是新來的IOS開發。我被困在一個地方,我想從void函數中使用該對象,在其他函數中使用該函數,這是我從該void函數調用的。你能告訴我怎麼做嗎?IPhone:發送類對象到不同的功能
下面的代碼:
-(void)buttonPressed: (id) sender withEvent: (UIEvent *) event{
UIButton *mybtn= (UIButton*) sender;
UserDetails *user; (user is the object of the UserDetails class which I want to use).
user= [searchResult objectAtIndex.:mybtn.tag];
[self sendInviteData]; (I want to use "user" in this function).
}
SearchResult
是具有從一個搜索欄搜索結果的數組。每個單元格中都有一個。當我點擊一個按鈕時,我想在用戶對象中獲取該數據並將其發送到sendInvite
函數。
謝謝叫它:)...我喜歡的方式。 – HakunaMatata
相當惱人的是@塞巴斯蒂安的答案比我的好 - 他的方法名解釋了你正在嘗試做的更多。你應該接受他的回答:( – deanWombourne