我有两个视图控制器,aViewController和bViewController,bViewController是aViewController的子类。我在aViewController中声明了一些属性,在bViewController中我可以读取该属性的值但是如果我尝试更改它们的值,则值不会改变并且在更改之前保持第一个。
答案 0 :(得分: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];