TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2016 |
SPMSupports SPM | ✓ |
Maintained by phimage.
Depends on: | |
Alamofire | ~> 4.0 |
Prephirences | ~> 3.0 |
Remote preferences and configurations for your application.
By using remote preferences you can remotely control the behavior of your app, allowing you to active a feature, to make impromptu A/B tests or to add a simple "message of the day".
It's built on top of Alamofire and Prephirences, and provides methods to load from remote plist
or json
files.
You can also have custom format like xml
or yaml
On your UserDefault
or any MutablePreferencesType
for plist
pref.loadPropertyList(from: "http://example.com/pref.plist")
...or if you need a callback for success/failure
pref.loadPropertyList(from: "http://example.Com/pref.plist",
completionHandler: { response in
switch response.result {
case .success:
...
case .failure(let error):
...
}
}
)
And for JSON
format, just change loadPropertyList
by loadJSON
pref.loadJSON(from: "http://example.com/pref.json")
You can also use custom alamofire DataResponseSerializer
, which must convert file to Dictionary
pref.load(from: "http://example.com/pref.ext", format: .custom(MyReponseSerializer))
Some repo with other format
For more complex request, instead of using simple URL, you can implement alamofire URLRequestConvertible
or provide your own 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.