2012-07-31 6 views
0

사이드 메뉴 앱이 있습니다.시작시보기 컨트롤러간에 데이터 전달

나는 2 ViewControllerRearViewControllerFrontViewController입니다.

RearViewController 나는 앱이 FrontViewController이 테이블에서 첫 번째 요소를로드하기 시작하면 바로 tableView을 원합니다.

가 나는 AppDelegate에서

frontViewController.category = [rearViewController.fetchedResultsController objectAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; 

추가 시도하지만, 얻을 모두가 전무 개체입니다. 감사합니다. 늘 같은 다른 하나의 뷰 컨트롤러에서 전송

+0

AppDelegate에 값이 없으므로 appDelegate에 nil이오고 있습니다. 해당 개체가 포함 된 메서드가 호출 될 때까지 개체에 아무런 가치가 없습니다 !! –

+0

그래, 나는 그것에 대해 생각했다. – Devfly

+0

당신은 무엇을 원하십니까 ..... ??? 변수를 뒤로 가져 가고 싶습니까? 어떻게 가능합니까? – TheTiger

답변

0

데이터는 .... 당신은 ... 그것을 밀어 ... 사용과 pushViewController 을 RearViewController 쓰기에서이

[self.navigationController pushViewController:FirstViewController animated:YES]; 
+0

나는 그것을 얻지 않는다. 내 루트 컨트롤러 FrontViewController, 그리고 무슨 뜻인지 이해할 수 없습니다. – Devfly

+0

처음 만났을 때 ... – IronManGill

0

enter image description here

이 경우 프로토콜을 사용합니다.

@protocol CommonDataSource 
- (TheType *)dataSource; 
@end 


@interface AppDelegate : NSObject <UIAppDelegate, CommonDataSource> 
@end 

@implementation AppDelegate 
- (TheType *)dataSource 
{ 
    ... 
} 
@end 


@interface TheAViewController : UIViewController 
@property (...) id<CommonDataSource> commonDataSource; 
@end 

@interface TheBViewController : UIViewController 
@property (...) id<CommonDataSource> commonDataSource; 
@end 


- (IBAction)theActionA:(id)sender 
{ 
    TheAViewController *aaa = ...; 
    a.commonDataSource = (AppDelegate*)...; 
} 


- (IBAction)theActionB:(id)sender 
{ 
    TheAViewController *aaa = ...; 
    a.commonDataSource = (AppDelegate*)...; 
} 

행운을 빈다!

+0

그것은 나를 위해 일하지 않습니다. 데이터를 표시 할 수 없습니다. – Devfly

관련 문제