Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  ReachabilityWrapper.swift   Sprache: JAVA

 

import CocoaLumberjack
import Foundation
import Reachability

final class ReachabilityWrapper: NSObject {
    
    private let reachability = try! Reachability()
    private var lastConnectionType: Reachability.Connection
    
    override init() {
        do {
            try reachability.startNotifier()
            self.lastConnectionType = reachability.connection
        }
        catch {
            DDLogNotice("Reachability init failed due to error: \(error.localizedDescription)")
            self.lastConnectionType = .unavailable
        }
        
        super.init()
    }
    
    deinit {
        reachability.stopNotifier()
    }
    
    @objc func isReachabilityUnavailable() -> Bool {
        lastConnectionType == .unavailable
    }
    
    @objc func didLastConnectionTypeChange() -> Bool {
        let newConnectionType = reachability.connection
        
        switch newConnectionType {
        case .unavailable:
            DDLogNotice("Internet is not reachable")
        case .wifi:
            DDLogNotice("Internet is reachable via WiFi")
        case .cellular:
            DDLogNotice("Internet is reachable via cellular")
        }
        
        if newConnectionType != lastConnectionType {
            lastConnectionType = newConnectionType
            return true
        }
        
        return false
    }
}

Messung
CHZG
80969690

¤ Dauer der Verarbeitung: 0.3 Sekunden  (vorverarbeitet am  2026-11-23) ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,187,842
#Domains=881,886