2017-02-07 9 views
1

NSMutableArray를 다른 테이블 뷰에 전달하고이를 테이블 뷰에 표시하려고합니다. I과 같이 데이터를 전송할객관적인 C 테이블 뷰 컨트롤러에 NSMutabelArray를 표시

2017-02-07 18:32:24.086 krib[13753:2978659] (
    "Balcony.png", 
    "Utilities Included.png", 
    "Air-conditioning.png", 
    "Stove.png", 
    "WiFi Included.png", 
    "Queen Bed.png", 
    "Dining Table.png", 
    "Washing Machine.png", 
    "Dryer.png", 
    "Sofa.png", 
    "TV.png", 
    "Curtains.png", 
    "Refrigerator.png", 
    "Water Heater.png", 
    "Microwave Oven.png" 
) 

,

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
if ([segue.identifier isEqualToString:@"segue"]) { 
    MZFormSheetPresentationViewControllerSegue *presentationSegue = (id)segue; 
    presentationSegue.formSheetPresentationController.presentationController.shouldApplyBackgroundBlurEffect = YES; 
    UINavigationController *navigationController = (id)presentationSegue.formSheetPresentationController.contentViewController; 
    AmennitiesTableTableViewController *presentedViewController = [navigationController.viewControllers firstObject]; 
//  presentedViewController.textFieldBecomeFirstResponder = YES; 

    presentedViewController.passingString = facilities; 

} 

테이블 뷰 컨트롤러에서 데이터를 수신

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(close)]; 

    NSLog(@"%@",self.passingString); 
    [self.tableView reloadData]; 

} 
I는 다음과 같이 변경 가능한 배열을 도시하려

,

다음과 같이 내있는 NSMutableArray은
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *cellIdentifier = @"facilitiesCell"; 
    AmenitiesTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
    cell.facilitylbl.text = [self.passingString objectAtIndex:indexPath.row]; 

    // Configure the cell... 

    return cell; 
} 

그러나 나는 tableview에서 데이터를 채우기 위해 정확히 무엇이 빠졌는지 이해하지 못하고있다.

+0

누락 된 정보 :'self.tableView'의'delegate'과'datasource'가 설정되어 있습니까? 'tableView : numberOfRowsInSection :''self.passingString.count'에 돌아 왔습니까? – Larme

+0

@ S.Sallay 콘솔 로그에서 오류 코드를 여기에 추가하십시오. –

+0

[UITableViewCell facilitylbl] : 인스턴스로 전송 된 인식 할 수없는 선택기 0x7f89c9c44400 2017-02-08 09 : 44 : 48.567 krib [914 : 49152] *** 캐치되지 않은 예외 'NSInvalidArgumentException'으로 인해 앱 종료 중, 이유 : '- [UITableViewCell facilitylbl] : 인식 할 수없는 셀렉터가 인스턴스 0x7f89c9c44400으로 전송되었습니다. ' 알림, NSMutable 배열을 사용합니다. – shamila

답변

1

나는 당신이 tableview 대리인 & 데이터 소스를 설정하는 것 같아요.

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(close)]; 
    [self.myTable setDelegate:self]; 
    [self.myTable setDataSource:self]; 

    NSLog(@"%@",self.passingString); 
    [self.tableView reloadData]; 

} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    return self.passingString.count; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *cellIdentifier = @"facilitiesCell"; 
    AmenitiesTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if(self.passingString.count > 0){ 
     cell.facilitylbl.text = [self.passingString objectAtIndex:indexPath.row]; 
    } 

// Configure the cell... 

    return cell; 
} 
+0

여전히 [UITableViewCell facilitylbl] 오류가 발생합니다. 알 수없는 선택기가 인스턴스 0x7f89c9c44400에 전송되었습니다. 2017-02-08 09 : 44 : 48.567 krib [914 : 49152] *** 잡히지 않은 앱 예외 'NSInvalidArgumentException', 이유 : '- [UITableViewCell facilitylbl] : 인스턴스로 전송 된 인식 할 수없는 선택기 0x7f89c9c44400' – shamila

+1

'편의 시설 테이블 이동'ID 검사기로 이동했는지 확인할 수 있습니다. 사용자 정의 클래스를 제공했는지 확인하십시오. 그리고 다시 한번 'facilitylbl'콘센트를 제거하고 다시 추가 할 수 있습니다. –

+0

이것은 내 속임수였습니다. 감사합니다 내 시간을 저장 – shamila