2013-02-27 275 views
0

我有兩個視圖控制器,aViewController和bViewController,bViewController是aViewController的子類。我在一個ViewController中聲明瞭一些屬性,在bViewController中我可以讀取該屬性的值,但是如果我嘗試更改它們的值,則該值不會更改,並且在更改前保持第一個值。更改屬性值

+2

帖子相關代碼或沒有人可以提供幫助。 – rmaddy 2013-02-27 17:00:56

+0

代碼或它沒有發生。 – graver 2013-02-27 17:01:11

+0

也許財產是在「複製」模式 – pdrcabrod 2013-02-27 17:01:55

回答

0

請確保您有這樣的事情:

// "A" view controller 
@interface AViewController : UIViewController 

@property (nonatomic, strong) NSString *name; 

@end 


// "B" view controller 
@interface BViewController : AViewController 

- (void)changePropertyValue; 

@end 

@implementation BViewController 

- (void)changePropertyValue 
{ 
    self.name = @"Bill"; 
    NSLog(self.name); 
    self.name = @"Steve"; 
    NSLog(self.name); 
} 

@end 

// create your BViewController 
BViewController *theController = [[BViewController alloc] init]; 
[theController changePropertyValue]; 
+0

好吧,這是正確的,但我的問題是,我想讀取新的值,在bViewController中更改,在aViewController – user1575803 2013-02-27 17:42:31