2011-06-15 63 views
0

已在TableView1.h中創建屬性屬性並將該屬性值推送到另一個視圖名稱TableView2。我如何訪問另一個視圖名稱TableView2.m中的Start屬性屬性。嘗試訪問UINavigationcontroller中的@property屬性

在TableView1.h

@interface TableView1 : UIViewController{ 
    NSString *Start; 
} 

@property (nonatomic, retain) NSString *Start; 

在TableView1.m在TableView1

@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]; 
} 
+0

爲什麼ü用 「UINavigationBar的」 – vikingosegundo 2011-06-15 22:04:02

回答

1

你不應該定義屬性開始

在TableView2.h

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

在表View2.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

+0

你覺得有更好的方式來標記這個做它?因爲我被告知可以通過使用@property方法來實現。 – lifemoveson 2011-06-15 22:06:28

+0

對不起,我誤解了你的問題。 – ZhangChn 2011-06-15 22:21:18

+0

實際上,我對你輸入的名字感到困惑。 ViewList和ListView以及startViewController.listView = view中的startViewController相同。 – lifemoveson 2011-06-15 22:30:42