using Foundation; namespace Blahblah.Library.Network; public class DownloadTask : ContentTask { public string FilePath { get; } protected override bool AllowDefaultResult => true; public DownloadTask(string url, string filePath, TaskCompletionSource> source, CancellationToken token) : base(url, source, token) { FilePath = filePath; } protected override bool Completed(NSHttpUrlResponse? response) { if (Data == null) { throw new NullReferenceException("Data is null"); } var result = Data.Save(FilePath, NSDataWritingOptions.Atomic, out NSError? error); if (error != null) { throw new Exception(error?.ToString() ?? "UUnknown error while saving file"); } return result; } }