self.nsme 和 _name 的问题

.h文件
@interface myclass:NSObject
@property(nonatomic,retain)NSArray*MyArray;
@end .m文件
@implementation myclass
-(void)viewDidLoad
{
[superviewDidLoad]; _MyArray=[[NSArrayalloc]initWithObjects:@"",nil];
NSLog(@"%lu",(unsignedlong)[self.MyArray retainCount]);//输出1 self.MyArray=[[NSArrayalloc]initWithObjects:@"",nil];
NSLog(@"%lu",(unsignedlong)[self.MyArray retainCount]);//输出2 我的理解是
self.MyArray=[[NSArrayalloc]initWithObjects:@"",nil];
相当于
NSArray*a=[[NSArrayalloc]initWithObjects:@"",nil];
self. MyArray =a;
而self.MyArray会调用myArray的set方法,
-(void)setMyArray:( NSArray *)Array
{
if(Array!= MyArray)
{
[MyArray release];
MyArray =[Array retain];
}
} }
上一篇:Shiro眼皮下玩ajax,玩出302 Found(实践得经验)


下一篇:Spring拓展接口之BeanFactoryPostProcessor,占位符与敏感信息解密原理