Bug 5903 - UITableView Source property is always null
Summary: UITableView Source property is always null
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.3.x
Hardware: Macintosh Other
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-28 05:29 UTC by Rolf
Modified: 2012-06-28 07:23 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Rolf 2012-06-28 05:29:13 UTC
The Source property of UITableView always returns null because the getter tries to cast the WeakDelegate into UITableViewSource. When using WeakDataSource it will result in a desired value.

Furthermore if the property would be changed to use WeakDataSource the getter can be reduced to one line unless in some cases the WeakDelegate should result in a value. 

Should the WeakDelegate be checked then the getter should do a double casting check and return the first non null casting, thus if WeakDelegate casting is not null else if WeakDatasource casting is not null.

Current Property in UITablveView:
public UITableViewSource Source {
	get {
		UITableViewSource uITableViewSource = this.WeakDelegate as UITableViewSource;
		if (uITableViewSource != null){
			return uITableViewSource;
		}
		return null;
	}
	set
	{
		this.WeakDelegate = value;
		this.WeakDataSource = value;
	}
}
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-06-28 07:23:10 UTC
Fixed to check both WeakDelegate and WeakDataSource. It will be included in 5.3.6.

master: e0de22905d362205e2451525848aa27b315f7c7f

Note that both WeakDataSource and WeakDelegate have strongly typed versions (DataSource and Delegate respectively) you can use.