I want to check network reachability using Alamofire. This is the code:
var body: some Scene {
WindowGroup {
NetworkReachabilityManager()!.startListening { status in
switch status {
case .notReachable, .unknown:
Text("No internet")
.bold()
.padding(.horizontal, 2)
.frame(maxWidth: .infinity)
.background(Color(hex: 0xce01e37))
.foregroundColor(Color.white)
default : ()
}
}
...
But this error keeps showing:
Static method 'buildBlock' requires that 'Bool' conform to 'View'
Any solutions ?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm trying to add functionality to save a picture from a URL to the user's photo library. here's the code:
import Foundation
import UIKit
class ImageDownloader: NSObject {
static func writeToPhotoAlbum(imageUrl: String) {
let imageURL = URL(string: imageUrl)!
if let image = try? Data(contentsOf: imageURL) {
UIImageWriteToSavedPhotosAlbum(UIImage(data: image)!, self, nil, nil)
}
}
@objc func saveCompleted(
_ image: UIImage,
didFinishSavingWithError error: Error?,
contextInfo: UnsafeRawPointer)
{
print("Save finished!")
}
}
When i call the method like this:
ImageDownloader.writeToPhotoAlbum(imageUrl: "image_url")
I get this error:
ImageDownloader does not respond to selector
Any explanation and solution?