Попытка получить доступ к атрибуту @property в UINavigationcontroller - PullRequest
0 голосов
/ 16 июня 2011

Создали свойство атрибута в TableView1.h и помещаем это значение атрибута в другое имя представления TableView2. Как я могу получить доступ к свойству атрибута Start в имени другого представления TableView2.m.

В TableView1.h

  @interface TableView1 : UIViewController{
    NSString *Start;
 }

@property (nonatomic, retain) NSString *Start;

В TableView1.m

@synthesize Start;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TableView2 *view2 = [[[TableView2 alloc] initWithNibName:@"TableView2" bundle:[NSBundle mainBundle]] autorelease] ;
view2.Start = [ NSString stringWithFormat:@"%@", [self.Array objectAtIndex:indexPath.row]];
[appDelegate.navController pushViewController:view2 animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

1 Ответ

1 голос
/ 16 июня 2011

Вы не должны определять свойство Start в TableView1

В TableView2.h

@interface TableView2 : SomeViewController {
  NSString * start;
}
@property (nonatomic, retain) NSString * start;
...

В TableView2.m

@synthesize start;

В TableView1.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   TableView2 *view2 = [[[TableView2 alloc] initWithNibName:@"TableView2" bundle:[NSBundle mainBundle]] autorelease] ;

   view2.start = [ NSString stringWithFormat:@"%@", [self.Array objectAtIndex:indexPath.row]];
   [appDelegate.navController pushViewController:view2 animated:YES];
   [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

В TableView2.m просто получить доступ self.start

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