LoginSignup
0
0

More than 5 years have passed since last update.

インスタンス変数・メソッドに外部からアクセスする方法

Posted at

・値をセットする場合
setValue: forKey:

・値を取得する場合
valueForKey:

例)

- (void)hogehoge
{
        OtherClass *obj = [[OtherClass alloc]init];
        [obj setValue:obj forKey:@"name"];
        NSLog(@"%@", [obj valueForKey:@"name"]);
    }
}

・参照:Objective-C Key-Value Coding
http://cx5software.com/blog/2012/01/01/objective-c-key-value-coding/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0