mirror of
				https://github.com/yggdrasil-network/yggdrasil-ios.git
				synced 2025-11-04 03:05:09 +03:00 
			
		
		
		
	Sanitised
This commit is contained in:
		
						commit
						52ca049b50
					
				
					 39 changed files with 3283 additions and 0 deletions
				
			
		
							
								
								
									
										28
									
								
								Yggdrasil Network iOS/Extensions/UIDevice.swift
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Yggdrasil Network iOS/Extensions/UIDevice.swift
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,28 @@
 | 
			
		|||
import Foundation
 | 
			
		||||
import UIKit
 | 
			
		||||
 | 
			
		||||
extension UIDevice {
 | 
			
		||||
    /// A Boolean value indicating whether the device has cellular data capabilities (true) or not (false).
 | 
			
		||||
    var hasCellularCapabilites: Bool {
 | 
			
		||||
        var addrs: UnsafeMutablePointer<ifaddrs>?
 | 
			
		||||
        var cursor: UnsafeMutablePointer<ifaddrs>?
 | 
			
		||||
        
 | 
			
		||||
        defer { freeifaddrs(addrs) }
 | 
			
		||||
        
 | 
			
		||||
        guard getifaddrs(&addrs) == 0 else { return false }
 | 
			
		||||
        cursor = addrs
 | 
			
		||||
        
 | 
			
		||||
        while cursor != nil {
 | 
			
		||||
            guard
 | 
			
		||||
                let utf8String = cursor?.pointee.ifa_name,
 | 
			
		||||
                let name = NSString(utf8String: utf8String),
 | 
			
		||||
                name == "pdp_ip0"
 | 
			
		||||
                else {
 | 
			
		||||
                    cursor = cursor?.pointee.ifa_next
 | 
			
		||||
                    continue
 | 
			
		||||
            }
 | 
			
		||||
            return true
 | 
			
		||||
        }
 | 
			
		||||
        return false
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue