2011-09-12 2 views
0

작성한 uitableviewcell에있는 텍스트 lable을 전달하려고하는데이를 수행하는 데 필요한 매개 변수가 확실하지 않습니다. 내가 너무 내있는 UITableViewCell 라벨에서 정보를 전달하고 싶은 곳uitableviewcell에서 NSObject로 NSString을 전달하는 방법

내가 매개 변수로있는 NSString 객체가있는 방법 NSObject라는이,이

은 내가 .H 파일을 #imported했다입니다 ... 그리고 뷰 tableViews 내부 객체 설정 : didSelectRowAtIndexPath 방법을하지만 난 그에게 lable가에서 텍스트를 전달하는 방법을 단지 확실하지 않다, 이것이 내가 시도 것입니다하지만 난 호환성 경고 ..

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {   
     //initalize object to hold search parameters 
     VehicleSearchObject *vehicleSearchObject = [[VehicleSearchObject alloc] init]; 


     [self.navigationController popViewControllerAnimated:YES]; //pops current view from the navigatoin stack 

     UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 

     //--- this if block allows only one cell selection at a time and is passing the text in the cells label back to the object 
     if (oldCheckedData == nil) { // No selection made yet 
      oldCheckedData = indexPath; 
      [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; 
      [vehicleSearchObject GetManufacturers:[[cell textLabel] objectAtIndex:[indexPath row]] // This is where I try to pass the text back but not sure how to do it.. 

     } 
     else { 
      UITableViewCell *formerSelectedcell = [tableView cellForRowAtIndexPath:oldCheckedData]; // finding the already selected cell 
      [formerSelectedcell setAccessoryType:UITableViewCellAccessoryNone]; 

      [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; // 'select' the new cell 
      oldCheckedData=indexPath; 
     } 
    } 

답변

1

당신은이 작업을 수행 할 수 있습니다.

[vehicleSearchObject GetManufacturers:cell.textLabel.text]; 
+0

감사합니다. –

+0

오신 것을 환영합니다! – EmptyStack

1

당신이 단순히 다음을 수행하여 셀 레이블 텍스트를 참조 할 수 있습니다.

cell.textLabel.text 

[vehicleSearchObject GetManufacturers:cell.textLabel.text]; 
0
[[cell textLabel] setText:[vehicleSearchObject GetManufacturers:[[cell textLabel] text]];