Xamarin是否會導致C#
內存泄漏?即可以釋放MyViewController還是具有循環引用,防止它?Xamarin UITableView Source是弱還是強?
在MyViewController:
this.TableView.Source = new ViewSource(this);
public class ViewSource : UITableViewSource
{
private readonly MyViewController parentController;
public ViewSource(MyViewController parentController)
{
this.parentController=parentController;
}
}
據:
Will a UITableViewController Garbage Collect if it instances a nested class referencing itself in a variable?這是沒有問題的。但是如果Source是弱點,那麼會發生什麼,如果你只有:
this.TableView.Source = new ViewSource();
Source可以從下一行發佈?無論哪種方式,這似乎是一個非常危險的API。