简体   繁体   中英

Changing value of property

i have two view controllers, aViewController and bViewController, bViewController is a subclass of aViewController. I have some properties declared in aViewController, in bViewController i can read the value of that properties but if i try to change their values, the value doesn't change and remain the first before the changing.

Please make sure that you have something like this:

// "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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM