I'm trying to understand the usage of protocol and delegates in Swift and their equivalence in c# for Xamarin.iOS.
Microsoft has a decent documentation about that here but for me it lacks the swift or objectiveC counterpart of c# code to allow me to understand what to do.
I'm in the process of porting an existing Swift gist to c# Xamarin iOS.
I have this protocol:
protocol GridLayoutDelegate: class {
func scaleForItem(inCollectionView collectionView: UICollectionView, withLayout layout: UICollectionViewLayout, atIndexPath indexPath: IndexPath) -> UInt
func itemFlexibleDimension(inCollectionView collectionView: UICollectionView, withLayout layout: UICollectionViewLayout, fixedDimension: CGFloat) -> CGFloat
func headerFlexibleDimension(inCollectionView collectionView: UICollectionView, withLayout layout: UICollectionViewLayout, fixedDimension: CGFloat) -> CGFloat
}
That I have converted to:
public interface IGridLayoutDelegate
{
uint ScaleForItem(UICollectionView collectionView, UICollectionViewLayout layout, NSIndexPath indexPath);
nfloat ItemFlexibleDimension(UICollectionView collectionView, UICollectionViewLayout layout, nfloat fixedDimension);
nfloat HeaderFlexibleDimension(UICollectionView collectionView, UICollectionViewLayout layout, nfloat fixedDimension);
}
So far so good.
Later in the code I have this (for now) strange declaration:
weak var delegate: GridLayoutDelegate?
What concerns me is that it is never assigned later in the swift code.
For now I have my c# class declared as:
public class GridLayout : UICollectionViewLayout, IGridLayoutDelegate
{
...
}
What would be the corresponding code in c#?