0

I am working on a ARC based project.

I have declared a property for tableView as follows

@property (weak, nonatomic) IBOutlet UITableView *logTable.

In the ViewDidLoad I do the following

 - (void)viewDidLoad
{
    [super viewDidLoad];

    [self.logTable.layer setCornerRadius:8.0f];//First Method

   /////OR

    [logTable.layer setCornerRadius:8.0f]; //Second Method

}

My question is, which is the best method i.e First or Second in my case?

I am aware that when we don't use self , we are directly accessing the ivar.But will it make

any difference in case of Weak properties.

EDIT:

Suppose if I have a strong Property as follows

@property(strong,nonatomic)NSArray *dataArray;

As far as I know , this will cause the memory leak

self.dataArray =[[NSArray alloc]init];

So which approach to be followed in this case ?

Any help is greatly appreciated.

4

1 回答 1

1

我建议使用self.for 属性,除非有必要的理由不这样做,例如在自定义访问方法中。当您在将来某个时间回来阅读它时,它会导致需要较少分析的代码,并且如果您决定有一天更改属性属性,它出现错误的机会就会减少。

于 2012-11-27T13:54:42.550 回答