self.view 与view 的区别苹果开发 内存问题

2024-11-16 02:17:53
推荐回答(1个)
回答1:

NSString *a1=[NSString stringWithFormat:@\\\\\\\"%.2f\\\\\\\", i];

{
1: a=a1; //相当于a = [a1 assign]; a1 retainCount不增加
2: self.a=a1; //相当于 a = [a1 retain]; a1 retainCount+1
}
{
3: a=@\\\\\\\"ddd\\\\\\\"; //当于 a = @\\\\\\\"ddd\\\\\\\";
4: self.a=@\\\\\\\"ddd\\\\\\\"; //相当于 a = [@\\\\\\\"ddd\\\\\\\" retain]
}
1和2,3和4 ,最主要差别在于有没有调用 property 的get set,从而影响是否有使用retain这些属性