Alamofire-Prephirences 2.0.0

Alamofire-Prephirences 2.0.0

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2016年10月
SPM支持SPM

phimage维护。



 
依赖
Alamofire~> 4.0
Prephirences~> 3.0
 

  • phimage

Alamofire - Prephirences

为您的应用程序提供远程首选项和配置。

通过使用远程首选项,您可以远程控制应用程序的行为,允许您激活功能,进行意外的A/B测试,或添加简单的“每日信息”。

它建立在AlamofirePrephirences之上,并为从远程的plistjson文件中加载提供方法。您还可以使用自定义格式,如xmlyaml

用法

从URL加载

UserDefault或任何MutablePreferencesTypeplist

 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))

带有其他格式的某些仓库

从URLRequest加载

对于更复杂的需求,您可以使用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.