2012-01-15 5 views
1

위임 나는이 오류를인식 할 수없는 선택, 문제

무엇입니까 [ResultViewController setSearchFields을 : IndexPath을 :] : 인식 할 수없는 선택기 내가 사용하고있는 네비게이션 컨트롤러의 스택을 가지고 예를 0xc448840

로 전송 델리게이트는 네비게이션 스택의 이전 뷰로 정보를 다시 전달합니다. 그러나 델리게이트를 선언 할 때 내가 뭔가 잘못하고 있다고 생각합니다.

내 탐색 스택은 다음과 같습니다. 내가보기에보기 3 대리자를 설정해야하는 경우 ... 궁금 오전 내가 뷰 1을 터지는 나는이 오류가 무엇입니까 그렇게함으로써 그러나 그보기로 위임 정보를 전달하고있는 중이 야

view 0 (mainmenu) 
-- view 1 (SearchViewController) 
--- view 2 (ResultViewController) - where I set the delegate of the new view being loaded 
---- View 3 (SubViewController) - this is where my delegates reside 

1 어디에 내가 정보를 전달 결국 ... 그게 맞지 ??

그렇다면 델리게이트를 설정할 때 무엇을 생각해야합니까? 내가

SubViewController

내 대리자를 설정하고있어 어떻게 subvc.m

@protocol PassSubSearchData <NSObject> 
@required 
- (void) setSearchFields:(NSArray *)modArray IndexPath:(NSIndexPath *)modIndexPath; 
@end 

@interface VehicleSubResultViewController : UITableViewController <NSXMLParserDelegate> { 
//.. 
//Delegate for passing Mod and SubMod data back to VehicleSearchViewController 
    id <PassSubSearchData> delegate; 
//.. 
//Delegate for passing Mod and SubMod data back to VehicleSearchViewController 
@property (strong) id delegate; 

subvc.h 이것은보기 1

를 호출 어떻게

#pragma mark - Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    //Access selected cells content (cell.textLabel.text) 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

    //Predicates restrict the values that will be returned from the query. 
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"SUB",cell.textLabel.text]; 
    filterArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate]; 

    [[self delegate] setSearchFields:tempModArray IndexPath:tempModIndexPath]; 

    //This pops to the View 1 - SearchViewController 
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES]; 

} 

다음 내 SearchViewController에서 이것은 위임 항목을 설정하는 방법입니다.

searchvc.h

#import "SubViewController.h" 

@interface SearchViewController : UITableViewController <PassSubSearchData> { 
//.. 

searchvc.m

- (void) setSearchFields:(NSArray *)modArray IndexPath:(NSIndexPath *)modIndexPath 
{ 
    modSearchObjectString = [[modArray valueForKey:@"MOD"] objectAtIndex:0]; 
    modSearchIndexPath = modIndexPath; // Sets the selected IndexPath from the subview 


    NSLog(@"%@", modSearchObjectString); 
    NSLog(@"%@", modResultIndexPath); 



    [self.tableView reloadData]; 
} 

그 지연 죄송 거의 요약 그것을 ....

+0

문제의 메서드 선언 및 메서드를 호출하는 코드를 사용하여 코드를 게시 할 수 있습니까? –

+0

예. 지금하고 있습니다. –

+0

나는 네가하고 싶은 일에 대해서 조금 불명확하다. 당신이 정말로 필요로하는 유일한 것은 테이블 뷰에서 다음 View Controller로 데이터를 전달하는 것입니다. PopUp이 말했습니다. –

답변

1

내가 말할 수있는 것부터 정보를 파일에 저장 한 다음 필요할 때 다시 가져 오는 것이 원하는 것을 성취하는 더 간단한 방법 일 수 있습니다. 이런 식으로 뭔가 (내가 아는 한, 아주 간략하게) :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    //store the cell's title into a string 
    NSString* string = [[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]; 

    [[NSUserDefaults standardUserDefaults] setObject:string forKey:@"someKey"]; 
} 

나중에 사용에 의해 다시 해당 문자열을 얻을 수 있습니다 :

NSString* titleString = [[NSUserDefaults standardUserDefaults] objectForKey:@"someKey"]; 

당신이 전송하는 데 필요한 정보와 함께이 같은 방법으로 진행할 수 있습니다.다음

//make sure you cast it 
(SearchViewController*)[self.navigationController.viewControllers objectAtIndex:1].string = @"some string"; 

당신이 이동하면 : 당신은 당신이보기 컨트롤러에 팝업 전에 다음

@property(nonatomic, retain) NSString* string; //you need to synthesize it in the .m file too 

:

또 다른 대안은 데이터를 수신 뷰 컨트롤러의 속성을 만드는 것입니다 컨트롤러에 설정하면 해당 속성은 사용자가 설정 한 문자열로 설정됩니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

그리고 이러한 방법으로 뷰 컨트롤러간에 정보를 전달할 수 있습니다. 행운을 빕니다!

+0

괜찮아요 멋지다 고마워, 이걸 줄거야. 몇 가지 조사를 해보고 내가 어떻게 시작하는지보십시오. 답장을 보내 주셔서 감사합니다. –

관련 문제