测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最新发布 | 2016年10月 |
SPM支持SPM | ✓ |
由phimage维护。
依赖 | |
Alamofire | ~> 4.0 |
Prephirences | ~> 3.0 |
通过使用远程首选项,您可以远程控制应用程序的行为,允许您激活功能,进行意外的A/B测试,或添加简单的“每日信息”。
它建立在Alamofire和Prephirences之上,并为从远程的plist
或json
文件中加载提供方法。您还可以使用自定义格式,如xml
或yaml
在UserDefault
或任何MutablePreferencesType
的plist
中
pref.loadPropertyList(from: "http://example.com/pref.plist")
...如果需要成功/失败的回调
pref.loadPropertyList(from: "http://example.Com/pref.plist",
completionHandler: { response in
switch response.result {
case .success:
...
case .failure(let error):
...
}
}
)
对于JSON
格式,只需将loadPropertyList
更改为loadJSON
pref.loadJSON(from: "http://example.com/pref.json")
您还可以使用自定义的alamofire DataResponseSerializer
,它必须将文件转换为Dictionary
pref.load(from: "http://example.com/pref.ext", format: .custom(MyReponseSerializer))
带有其他格式的某些仓库
对于更复杂的需求,您可以使用alamofire的URLRequestConvertible
实现或提供您自己的URLRequest
let url = URL(string: "http://example.com/pref.plist")!
var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "GET"
... (add HTTPHeader, etc...)
mutablePref.loadPropertyList(from: urlRequest)
The MIT License (MIT)
Copyright (c) 2015 Eric Marchand (phimage)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.