public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) { var destination = (segue.DestinationViewController as UINavigationController)?.TopViewController as AssetGridViewController; if (destination == null) { throw new InvalidProgramException("unexpected view controller for segue"); } var cell = sender as UITableViewCell; if (destination == null) { throw new InvalidProgramException("unexpected cell for segue"); } destination.Title = cell.TextLabel.Text; switch (segue.Identifier) { case showAllPhotos: destination.FetchResult = allPhotos; break; case showCollection: // get the asset collection for the selected row var indexPath = TableView.IndexPathForCell(cell); PHCollection collection = null; switch ((Section)indexPath.Section) { case Section.SmartAlbums: collection = (PHAssetCollection)smartAlbums.ObjectAt(indexPath.Row); break; case Section.UserCollections: collection = (PHCollection)userCollections.ObjectAt(indexPath.Row); break; } // configure the view controller with the asset collection var assetCollection = collection as PHAssetCollection; if (assetCollection == null) { throw new InvalidProgramException("expected asset collection"); } destination.FetchResult = PHAsset.FetchAssets(assetCollection, null); destination.AssetCollection = assetCollection; break; } }
public Item this[int index] => new Item((PHAsset)_fetchResult.ObjectAt(index));