0

我有两个视图控制器,aViewController 和 bViewController,bViewController 是 aViewController 的子类。我在 aViewController 中声明了一些属性,在 bViewController 中我可以读取该属性的值,但是如果我尝试更改它们的值,则该值不会更改并且在更改之前保持第一个。

4

1 回答 1

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];
于 2013-02-27T17:17:46.270 回答