# Reachability.swift
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.
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](https://itunes.apple.com/app/apple-store/id1252374855?pt=215893&ct=reachability&mt=8)…
Devices | Layout | Copy | Localize | Export
:------:|:------:|:------:|:------:|:------:
![](http://is2.mzstatic.com/image/thumb/Purple118/v4/64/af/55/64af55bc-2ef0-691c-f5f3-4963685f7f63/source/552x414bb.jpg) | ![](http://is4.mzstatic.com/image/thumb/Purple128/v4/fb/4c/bd/fb4cbd2f-dd04-22ba-4fdf-5ac652693fb8/source/552x414bb.jpg) | ![](http://is1.mzstatic.com/image/thumb/Purple118/v4/5a/4f/cf/5a4fcfdf-ca04-0307-9f2e-83178e8ad90d/source/552x414bb.jpg) | ![](http://is4.mzstatic.com/image/thumb/Purple128/v4/17/ea/56/17ea562e-e045-96e7-fcac-cfaaf4f499fd/source/552x414bb.jpg) | ![](http://is4.mzstatic.com/image/thumb/Purple118/v4/59/9e/dd/599edd50-f05c-f413-8e88-e614731fd828/source/552x414bb.jpg)
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:
1. Make sure CocoaPods is [installed][CocoaPods Installation].
2. Update your Podfile to include the following:
``` ruby
use_frameworks!
pod 'ReachabilitySwift'
```
3. Run `pod install`.
[CocoaPods]: https://cocoapods.org
[CocoaPods Installation]: https://guides.cocoapods.org/using/getting-started.html#getting-started
4. 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:
1. Install Carthage via [Homebrew][]
```bash
$ brew update
$ brew install carthage
```
2. Add `github "ashleymills/Reachability.swift"` to your Cartfile.
3. Run `carthage update`.
4. Drag `Reachability.framework` from the `Carthage/Build/iOS/` directory to the `Linked Frameworks and Libraries` section of your Xcode project’s `General` settings.
5. Add `$(SRCROOT)/Carthage/Build/iOS/Reachability.framework` to `Input Files` of Run Script Phase for Carthage.
6. In your code import Reachability like so:
`import Reachability`
[Carthage]: https://github.com/Carthage/Carthage
[Homebrew]: http://brew.sh
[Photo Flipper]: https://itunes.apple.com/app/apple-store/id749627884?pt=215893&ct=GitHubReachability&mt=8
## Example - closures
NOTE: All closures are run on the **main queue**.
```swift
//declare this property where it won't go out of scope relative to your listener
let reachability = 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
```swift
reachability.stopNotifier()
```
## Example - notifications
NOTE: All notifications are delivered on the **main queue**.
```swift
//declare this property where it won't go out of scope relative to your listener
let reachability = 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
```swift
@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")
}
}
```
and for stopping notifications
```swift
reachability.stopNotifier()
NotificationCenter.default.removeObserver(self, name: .reachabilityChanged, object: reachability)
```
## Want to help?
Got a bug fix, or a new feature? Create a pull request and go for it!
## Let me know!
If you use **Reachability.swift**, please let me know about your app and I'll put a link [here…](https://github.com/ashleymills/Reachability.swift/wiki/Apps-using-Reachability.swift) and tell your friends!
Cheers,
Ash
没有合适的资源?快使用搜索试试~ 我知道了~
基于自身项目搭建的一个flutter框架
共620个文件
dart:46个
png:37个
xcconfig:36个
需积分: 5 1 下载量 199 浏览量
2023-06-02
17:14:13
上传
评论
收藏 1.2MB ZIP 举报
温馨提示
1. 该框架使用GetX进行状态、路由管理; 2. 集成flutter_easyloading插件,实现了loading/toast; 3. flutter_screenutil插件,UI适配; 4. 基于dio实现了get/post网络请求,并调用免费天气api举例; 5. connectivity_plus判断应用网络状态; 6. flutter_inappwebview加载网页; ... 资源上传前进行了flutter clean,下载并解压后,请先pub get PS: 使用该flutter框架,已上架多个iOS/Android应用,并已迭代多次,时间跨度已近两年
资源推荐
资源详情
资源评论
收起资源包目录
基于自身项目搭建的一个flutter框架 (620个子文件)
03a899cca1d5ec18c3126e68a497db226604fd 139B
06bfbb1e591234473761fc06118e79533b5dd8 395B
099f378a9ce05a85080b0f5291f65fb71d089f 306B
0c9fe8fe773cc8b59788ba6814c4e39de4b5da 131B
0d364fa4b45f4211b8e37e8768c692ceb5cb7d 49B
0d7387b7e75957a0a205a5e3fdc5951959180d 57B
0d983b589d470f181cb0a0c035dc3be4e78d18 130B
0dbba97f29a0d912cb5f24e1591c2883d489da 68B
0edecb681d94c6c727cb79ef70af7a8f28f3e3 201B
0ee7bb7975fed95ec9ac143945dd3136c06258 281B
0f762ff1d78c8e140a471b32132799351b8b7d 2KB
10b0c1946e98765eba3c668f1d2bdbb58f4236 224B
11d3127371c4a155c6ccaa6907a13b8a73adbe 289B
126fbeefb7b28b6765531777c1971838b53bcb 46B
12e7dcf54871fbda29d613489277db5f9bd2b7 467B
1364b640ff9bfb67e4c717c2e3b873829a7e7b 502B
14700a6925ad1e6efb0b91e1e5836d7a1aee17 1KB
1489971ef842514f99ac9b966507729d5a5a5e 288B
14f5ffff2456d122aa7612b82f099953dcb23e 133B
155ae415d63637364f1b6461ef963481464d5b 97KB
15e1f763418f0a2e4aaed6fa71d3ba3a228b6e 67B
1632cfddf3d9dade342351e627a0a75609fb46 2KB
1664f2f28a708fa033226809b28b339e8d0698 725B
16a59bac46a8c98bc4fdfae20b373a939aec6f 219B
1773cd857a8a0f0c9c7d3dc3f5ff4fb298dc10 724B
18219a734fa0bd313018c530f503b5b97b227a 6KB
186764197b94497fe5bb6632c868dfb3ff8372 151B
18c9f5395573cfd0fb8290b7ac946030f11ec6 213B
1ef88056edd1caf99a935e434e7ff6943a0ef6 486B
1f5421f49d28dec0d9c5049022f974fa17e5ef 1KB
20b3155504863240482a6567f824bc41ec6476 315B
2139c5a9836ba9ecf8e46cc195b503ccb3dadd 59B
224b6697dfe54af0c20738790686a79045ba47 87B
25e105df39e8429814f3189a8015087720cba1 333B
2694c9d7a485fdd17a1f694171d255c9781420 426B
27aeeab777336a9c02f88595a50ecd79243cb0 1KB
28af18bc60a27fc628e6298a32f66556074312 209B
2adcb34c2d30f4e7e4426422385dfa72f63114 915B
2be3d46fd77256286fda71609af5038a2b0a90 209B
2eb4cdc49ba7ab6e1b7b5e464350a81bf2bee3 196B
2f463a9bc882b461c96aadf492d1729e49e725 606B
2fa1a4728ae4789e3bca55dd07caef3b41f2a5 198B
3142e71bfc751ce1d7a7d46406235425786005 262B
33779e9f54010e6a54b1dd02c6ea06c2593b69 2KB
33806e00ab9e127e989efc2c69e1594eeb09d7 55B
368af0ee7628fa194ef8fe3bbe4523113d6e05 60B
374ff6672335e8737b89630093eba6e46f88c0 508B
3945f1d7e8eed1ba7225db5f891ab048e0af45 264B
39def49266e395c1ed81716a814641edeae191 315B
3ba16fbd5ca7601983a425aa44372854592e67 264B
3c8144b6c871e85f973c5949ef82aaa28062c7 201B
3cc9b8ba4e4ae5c6df5ed5e3f199668b7fead0 68B
3d1755b50297a3e61a0018a43d6fde2bee3181 156B
3ee689d92faf9ff3ee272ffee4c807764151ef 126B
3ef6437726b9d1558eda97582804175c0010a2 169B
3f5fa40fb3d1e0710331a48de5d256da3f275d 518B
4085f3f6a2b995f8ad1f9ff7b2c46dc118a9e0 284B
412892bf0e477bec8435a10087ddff77dd513a 68B
4412a4fd0c73ffc463a6434f3c2a32fad795ab 131B
441fe50da5ca3a915adc50ce6061d696b4f65d 3KB
44773e132a2cdb5f48f5b83e83273c9174297a 596B
453c92da3e36e386d4fbca6777367d6f7fa1b2 963B
46021e5e353f2f827b3a136a02d0f53631c785 110B
460c836653870b4e9bd5d6a3e741b533bc9686 508B
46f99b7d19fac94d7087f8397fe9ea840b000e 476B
46fbca42302b8138bd5db53c836157a441849b 502B
472b99c6f3501ff93513bcdf39dabe4f236a55 139B
4732f8842013497e14bd02f67a55f2614fb8f7 280B
4793e357076c0b713148d39c488bda6c0ab720 60B
48be131d26267708d081a3a68d9b1883fb7960 98B
49f61f22ccb6b81e00e8de3fab124aa987693d 120B
4b392488f984b12f1b8f716c17c952a43b5d38 121B
4baff936f3a2cbf97f1f350138fcbd805e5ba8 123B
4cfdd96a89b0095dbd29a6ca194e41ad77b4fd 64B
4d23fccfa1bb167b53ad0c5f7f639e5959c3f0 2KB
526a16ed0f1cd0c2409d848bf489b93fefa3b2 133B
53c41ecf9ca08017312dc233d9830079b50717 315B
53cba09064923c5daf2d37e7c3c836ccdd794b 1KB
568019d3c69d4966bb5a0f759980a1472afc1e 208B
5714650f3ceda9ead751c2bea993690dbdb46f 121B
576f888a925fb53bbeb37cac70a0951471cfc0 49B
577de2f7273083bace0aa99c672294ad6d98ba 1KB
5863c192b86497b994ece2e13458698951cbd1 426B
58c378720b2eded18318860694e2b01020ab7a 156B
5a933abf2e14ef361e8e719b8276fa3f66f8c6 330B
5b8daf9df33c2bc780657d0fa07a1ebd82296c 133B
5c9938ab636e1c229081904095d90dae5ca9a7 56B
5e096282fcec09ff75face5f8a4828db2a7b67 98B
5ee7cb742a0af0548f9324931e506cdae66097 60B
5f6c0495b32a76bbf7b639e3f51094c2491ea9 155B
606462e0a2232e7e340f7f04068809cdfc818a 114B
61805f349e40cafd64397660b9391a1cb1f339 2KB
61888fc93faf7bcbaaa4229c7a5fa297fa6d6f 123B
61c53178cc135119f252e047fb2f6e08512ed0 60B
624d0cf9f308d5b6b35461cad2dada16d4e097 115B
6372eebdb28e45604e46eeda8dd24651419bc0 1KB
64d12b80605a9d84db9576068f92111a431a37 419B
651e8d217d40f48e95999bbd575d64c2c76dc5 5KB
651fda5fbc1e0e728fe38d2abc65f7250c177d 59B
655db88b439511a2fa69415f09cc90c76892b0 507B
共 620 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
CoderHuangHuang
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功