mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-27 02:37:42 +00:00
Merge pull request #2191 from keymanapp/ios-model-package-version
[iOS] Model installation - use of package version
This commit is contained in:
commit
00a7a81345
1 changed files with 18 additions and 1 deletions
|
|
@ -697,11 +697,28 @@ public class Manager: NSObject, UIGestureRecognizerDelegate {
|
|||
let data = try Data(contentsOf: path, options: .mappedIfSafe)
|
||||
let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
|
||||
if let jsonResult = jsonResult as? [String:AnyObject] {
|
||||
var version: String = "1.0"
|
||||
|
||||
if let info = jsonResult["info"] as? [String:AnyObject] {
|
||||
if let versionEntry = info["version"] as? [String:AnyObject] {
|
||||
if let description = versionEntry["description"] as? String {
|
||||
version = description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version uses a 'conditional initializer'. If it fails, the version info is invalid.
|
||||
if let _ = Version(version) {
|
||||
// No problem
|
||||
} else {
|
||||
// Lazy-handle the error and replace version with 1.0. Legacy decision from 2005.
|
||||
version = "1.0"
|
||||
}
|
||||
|
||||
if let lexicalModels = jsonResult["lexicalModels"] as? [[String:AnyObject]] {
|
||||
for k in lexicalModels {
|
||||
let name = k["name"] as! String
|
||||
let lexicalModelID = k["id"] as! String
|
||||
let version = k["version"] as! String
|
||||
|
||||
//TODO: handle errors if languages do not exist
|
||||
//var languageName = ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue