8.0k sao GitHub và vẫn tăng — ashleymills/Reachability.swift là dự án Swift mà TopGit đang theo dõi trên nền tảng. Replacement for Apple's Reachability re-written in Swift with closures
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Reachability.swift is a replacement for Apple's Reachability sample, re-written in Swift with closures.
It is compatible with iOS (8.0 - 12.0), OSX (10.9 - 10.14) and tvOS (9.0 - 12.0)
Inspired by https://github.com/tonymillion/Reachability
Supporting Reachability.swift
Keeping Reachability.swift up-to-date is a time consuming task. Making updates, reviewing pull requests, responding to issues and answering emails all take time.
Please consider sponsoring me https://github.com/sponsors/ashleymills, it's a great way to say thanks!
If you're an iOS developer who's looking for a quick and easy way to create App Store screenshots, please try out my app Screenshot Producer…
Devices
Layout
Copy
Localize
Export
And don't forget to ★ the repo. This increases its visibility and encourages others to contribute.
Thanks
Ash
Got a problem?
Please read https://github.com/ashleymills/Reachability.swift/blob/master/CONTRIBUTING.md before raising an issue.
Installation
Manual
Just drop the Reachability.swift file into your project. That's it!
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. To install Reachability.swift with CocoaPods:
Make sure CocoaPods is installed.
Update your Podfile to include the following:
use_frameworks!
pod 'ReachabilitySwift'
Run pod install.
In your code import Reachability like so:
import Reachability
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
To install Reachability.swift with Carthage:
Install Carthage via Homebrew
$ brew update
$ brew install carthage
Add github "ashleymills/Reachability.swift" to your Cartfile.
Run carthage update.
Drag Reachability.framework from the Carthage/Build/iOS/ directory to the Linked Frameworks and Libraries section of your Xcode project’s General settings.
Add $(SRCROOT)/Carthage/Build/iOS/Reachability.framework to Input Files of Run Script Phase for Carthage.
In your code import Reachability like so:
import Reachability
Swift Package Manager (SPM)
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. To integrate using Apple's Swift package manager from xcode :
File -> Swift Packages -> Add Package Dependency...
Enter package URL : https://github.com/ashleymills/Reachability.swift, choose the latest release
Example - closures
NOTE: All closures are run on the main queue.
//declare this property where it won't go out of scope relative to your listener
let reachability = try! Reachability()
reachability.whenReachable = { reachability in
if reachability.connection == .wifi {
print("Reachable via WiFi")
} else {
print("Reachable via Cellular")
}
}
reachability.whenUnreachable = { _ in
print("Not reachable")
}
do {
try reachability.startNotifier()
} catch {
print("Unable to start notifier")
}
and for stopping notifications
reachability.stopNotifier()
Example - notifications
NOTE: All notifications are delivered on the main queue.
//declare this property where it won't go out of scope relative to your listener
let reachability = try! Reachability()
//declare this inside of viewWillAppear
NotificationCenter.default.addObserver(self, selector: #selector(reachabilityChanged(note:)), name: .reachabilityChanged, object: reachability)
do{
try reachability.startNotifier()
}catch{
print("could not start reachability notifier")
}
and
@objc func reachabilityChanged(note: Notification) {
let reachability = note.object as! Reachability
switch reachability.connection {
case .wifi:
print("Reachable via WiFi")
case .cellular:
print("Reachable via Cellular")
case .unavailable:
print("Network not reachable")
}
}
ashleymills/Reachability.swift có phải mã nguồn mở không?
Có — ashleymills/Reachability.swift phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/ashleymills/Reachability.swift.
ashleymills/Reachability.swift có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho ashleymills/Reachability.swift. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
ashleymills/Reachability.swift dùng license gì?
ashleymills/Reachability.swift phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
ashleymills/Reachability.swift là gì?
ashleymills/Reachability.swift (ashleymills/Reachability.swift) là dự án Swift trên GitHub. Theo mô tả gốc: Replacement for Apple's Reachability re-written in Swift with closures
Đọc thêm về ashleymills/Reachability.swift ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/ashleymills/Reachability.swift là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về Reachability.swift?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về Reachability.swift.