属性值我已阅读,这样无法读取扩展
类扩展还专为允许财产公开
readonly
,私下readwrite
。
所以我做了一个有CLAS abc
下面的代码:
@interface abc()
@property (strong,nonatomic) NSString *sampleString;
@end
@implementation abc
@end
我想在abc
我做了一个类pqr
子类abc
另一个类的子类来acceess sampleString
在pqr
我正在尝试访问sampleStr
但不是可以做到这一点。
@implementation cccc
- (void)accessPrivateMember
{
self.sampleStr ; //Not able to acces
}
@end
我的方向错了吗?
因为'sampleString'不在类的公共接口中。在你的类的'.h'文件中声明这个属性。 – Adeel
在abc.h中添加只读属性作为@property(强,非原子,只读)NSString * sampleString; – kaushal