как получить идентификатор из массива и передать его в следующем представлении со значением в соответствии с идентификатором в iphone - PullRequest
0 голосов
/ 24 января 2012

У меня есть массив элементов, и массив содержит строковое значение и идентификатор. Я хочу получить идентификатор из массива при выборе строки в табличном представлении. Если я выберу любую строку, тогда идентификатор должен передать следующий класс представления, чтобы обновить данные для следующего представления.Я пытаюсь, но я путаю, как передать идентификатор со всеми данными для следующего просмотра для изменения

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [MyTableview deselectRowAtIndexPath:indexPath animated:YES];
    if (self.editing) {
        //Here
       //modal is my class where i create all string variable and id variable to get database value
       // here i want to pass id with next view please help here how to pass id at indexpath.row
        modal* a=(modal*)[listitems objectAtIndex:indexPath.row];

        if ([self.lstTasks objectAtIndex:indexPath.row]==(NSInteger) a.Id)

        EditTask* content = [[EditTask alloc] initWithNibName:@"EditTask" bundle:nil];
        content.navigationItem.title = @"Edit Task";
        navController = [[UINavigationController alloc] initWithRootViewController: content]; 
        _popover = [[UIPopoverController alloc] 
                    initWithContentViewController:navController];
         [content release];
        [navController release];

        _popover = [[UIPopoverController alloc] 
                    initWithContentViewController:navController];
        _popover.popoverContentSize = CGSizeMake(350, 450);
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        [_popover presentPopoverFromRect:cell.bounds inView:cell.contentView 
                permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        //}
    }   
}

1 Ответ

0 голосов
/ 24 января 2012

реализуйте следующее в следующем классе viewController

in interface
ObjectClass* object;

- (id)initWithId:(id)object;

в реализации

- (id) initWithId:(id)object
{
     self = [super init];
     if (self)
      {
          object = [object retain];
      }
}

и в методе didSelect

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
   // get the object
   nextVC* next = [[nextVC alloc] initWithId:object];
   [self.navigationController pushViewController:next animated:YES];
   [next release];
 }

таким образом вы можете передать любойОбъект для вашего следующего представления, это будет вызвано перед viewDidLoad следующего класса ..

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...